Thursday, March 3, 2011

What is the route to catch the default page?

Hi,

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).

From stackoverflow
  • 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 = "" });
            }
    
    Chris : Arbitrary name. I also experimented with "Default2", "Blank", etc... and liked "Empty" the best. :P

0 comments:

Post a Comment