0

I can access Ping.HTML and Ping.ASPX but when I try to access the view from my MVC (4.0) project (deployed to the same server, the bogus one, by F5), I get 404.

It's a vanilla project created from the template for MVC 4 with a very default view and controller (no model).

Hints on how to resolved it? I'm out of ideas...

EDIT

My RouteConfig.cs is like this

public class RouteConfig
{
  public static void RegisterRoutes(RouteCollection routes)
  {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { 
        controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
  }
}

Controllers folder contains only one, single file called ÄDefault1Controller.cs*. It only does this:

public class Default1Controller : Controller
{
  public ActionResult Index()
  {
    return View();
  }

  public ActionResult Test()
  {
    return View();
  }
}

EDIT

The exact URLs typed in (besides the server name alone, of course) are:

> http://localhost:49642/Index  
> http://localhost:49642/Index.aspx  
> http://localhost:49642/Home/Index  
> http://localhost:49642/Home/Index.aspx  
> http://localhost:49642/Default/Index  
> http://localhost:49642/Default/Index.aspx
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • The default that is executed on Win 7 with VS 2010. This far I'm only doing F5-execution. I'm taking over a pre-existent system and at the moment things are a bit unclear. :) – Konrad Viltersten Oct 25 '13 at 11:28
  • Are you trying to request a file (maybe a .cshtml) inside the ``Views`` folder? If so, check out question http://stackoverflow.com/questions/9468683/mvc-accessing-css-image-js-files-in-view-folder – acfrancis Oct 25 '13 at 11:29
  • @acfrancis I'm requesting the file called *View1.ASPX* created by a default *add view* context menu. The only added text is "*beep*" in there in a DIV. – Konrad Viltersten Oct 25 '13 at 11:36
  • Is it inside the ``Views`` folder? If so, put the file somewhere else like your application root folder. – acfrancis Oct 25 '13 at 11:38
  • @acfrancis The same misbehavior remains. I've commented away the verb of type *Http.Not.Found.Handler* too for the *Views*... Also, I'd prefer to keep my views in *Views*. :) – Konrad Viltersten Oct 25 '13 at 11:45
  • @Matt Not sure how to determine it. It's looks like the server exceptions thrown, if that's what you mean (style-wise, that is). But it looks the same when I intentionally misspell the name. – Konrad Viltersten Oct 25 '13 at 11:47
  • 1
    What do you mean by "commented away the verb"? Did you remove the whole line? Anyway, views are meant to be used as the return value of a controller action. You shouldn't try to request them directly from the browser. – acfrancis Oct 25 '13 at 11:52
  • Nope. I get: *Error in application /.* and *the resource can't be found* with description *HTTP 404*... – Konrad Viltersten Oct 25 '13 at 11:52
  • @acfrancis Yes I commented out the line in CONFIG file. As for the view, I'm trying to access *Index.ASPX* and the method *Index* is declared in my controller returning the value of type *ActionResult*. Is my controller perhaps not connected? How can I investigate that?! – Konrad Viltersten Oct 25 '13 at 11:55
  • This is turning into a chat. Please edit the question with more information about the files and folder structure in your application, the controller action involed and the browser request you made. – acfrancis Oct 25 '13 at 11:57
  • All that information **is** listed already in the question. Default project, running F5, file not rendered/accessible. – Konrad Viltersten Oct 25 '13 at 12:00
  • Based on the information you've given, it sounds like a routing problem. The URL you are requesting isn't firing a controller. Can you add details of the Request and what's in your controllers folder? – Matt Griffiths Oct 25 '13 at 12:11
  • What exact address are you typing in your browser address bar? Is it `http://localhost:123/Home/Index` or `http://localhost:123/Views/Index.aspx`? – Darin Dimitrov Oct 25 '13 at 13:05
  • @DarinDimitrov Great follow-up question! Please see the edit #2. – Konrad Viltersten Oct 25 '13 at 13:46

1 Answers1

1

Based on the information you've given, it sounds like a routing problem. The URL you are requesting isn't firing a controller.

EDIT

MVC works by convention, so by naming your controller Default1Controller the matching URL would start with /Default1.

In the example you've given, you can only access the Test() method by navigating to http://localhost:49642/Default1/Test, which will return the view typically located at /Views/Default1/Test.aspx (or /Views/Default1/Test.cshtml for razor-based views).

Please check out the routing overview at ASP.NET for more information about how the route table maps to controllers and actions. I should point out that the link is for the older versions of MVC, but you should get the idea.

Let me know if I can help further.

Matt

Matt Griffiths
  • 1,142
  • 8
  • 26
  • I've set default to *controller = "Home"* and *action = "Index"*, so the F5-press should go ti that line, right? How can I **make** the stupid server route to the correct address?! Do I need to skip the default routing?! – Konrad Viltersten Oct 25 '13 at 13:54
  • Yes, the default request will point to a controller called HomeController with an method Index() that will return a view located at /Views/Home/Index.aspx – Matt Griffiths Oct 25 '13 at 13:57
  • Oh, your edit made it work almost all the way. The correct suffix after localhost is */Default1/Test*. That shows. However, for some reason, */Default1/Index* doesn't... Hints? – Konrad Viltersten Oct 25 '13 at 14:04
  • Do you have an index view at /Views/Default1/Index.aspx (or Index.cshtml)? – Matt Griffiths Oct 25 '13 at 14:04
  • Poo... I **HAD** index view. It's been removed by an idiot during my (somewhat frustrated and confused) debug process. (Let's not point fingers at the idiot. It's me, though.) – Konrad Viltersten Oct 25 '13 at 14:07