Reputation: 580
I am working on an app and when I go to debug the application starts at: localhost:54591/Views/Home/Index.aspx and gives me a resource not found 404 error.
I get this same issue when I type in the url: localhost:54591/Views/Home/Index.aspx
But for some reason when I type in the url: localhost:54591/Views/Home/
It works but now my header menu is not formatted correctly.
So what gives? For the life of me I cannot figure out what is wrong. If I can just figure out how to reroute at startup to localhost:54591/Views/Home/ I could figure out why the menu is not working but I do have a hunch that these problems are related.
public static void RegisterRoutes(RouteCollection routes)
{
// routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
Any help is greatly appreciated.
Upvotes: 1
Views: 62
Reputation: 100547
It is not caused by routing (except 404 on non-existent page). By default VS will start web sites on page you are currently working on. So if you worked on Index.aspx at the moment of clicking F5 it will try to open that view.
To change the behavior - change start page in project's settings: Project properties -> Web -> change to "specific page".
Upvotes: 2
Reputation: 3221
localhost:54591/Views/Home/Index.aspx shouldn't work as you should be using the controller to load the views. /Home/ for example
Upvotes: 1
Reputation: 36146
That is the expected behaviour. On an MVC app you shouldnt access your views directly, instead, your contorllers.
Regarding the format issue, you would have to provide more details, but you App is working fine
Upvotes: 0