Tuesday 7 December 2010

Catch-All MVC Route

A weird scenario may come up where you want all requests to an application routed to just one controller action in an ASP.Net MVC application, here's the catch-all route you'll need :)

public static void RegisterRoutes(RouteCollection routes)
{
   routes.MapRoute(
      "Default", // Route name
      "{*catchall}", // URL with parameters
      new { controller = "Home", action = "Index" } // Parameter defaults
   );
}

1 comment:

  1. Hey! thanks for useful review. It was easy to read, but I'd like to add that if your business needs to be updated try outsource software development company.

    ReplyDelete