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 = "" } // Parameter defaults
);
}
As you can see the default directory is Home, and if anyone has created a none empty ASP.Net MVC project then you should be quite familiar with the HomeController.
I wasn't sure why they chose Home to be the default directory when I found it much more logical to make it Public.
So do the following
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Public", action = "Index", id = "" } // Parameter defaults
);
}
Changing the Home to Public makes the route search in the Public folder for the content when the website is fired up. Ah ha! I thought this is what I want, however, I wasn't done.
I had to do the following 2 things to get the website up and running without getting the Yellow Screen of Death.
First, I had to change the controller name from HomeController to PublicController. Remember it's not a controller if the prefix isn't Controller with a capital C.
Second, in the Views directory I had to rename Home to Public.
There as simple as that. I have changed the default directory of my website in ASP.Net MVC 1.0 and 2.0 to Home to Public.
Home this serves a purpose





MultiQuote


|