What is the route to catch the default page?
-
10-07-2019 - |
Question
I don't want to use the default route that vs.net creates:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
I only want the route to get the www.example.com/ page, what is it? (note: I don't want www.example.com/default just the plain www.example.com to map to HomeController Action=Index).
Solution
I just started playing around with MVC yesterday (the beta version) and I have this in my web config (for IIS 6.0, remove the .aspx for IIS 7.0)
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Default", "{controller}.aspx/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
routes.MapRoute("Empty", "", new { controller = "Home", action = "Index", id = "" });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow