Redirect to the default full URL with mvc3

advertisements

I want to give the users a friendly URL, with the desired area, and whenever they enter it, the site is forwarded to the default controller/action., but I am having a real hard time figuring out how to do it.

Example: someone types http://mySite.com/System and the routing engine redirects to the complete default url http://mySite.com/System/Auth/SignIn

I tried this, but it isn't working

routes.MapRoute(
   "System",                                       // Route name
   "System/{controller}/{action}",                 // URL with parameters
   new { area = "System", controller = "Auth",
   action = "SignIn", id = UrlParameter.Optional } // Parameter defaults
);

PS: as I am using areas, System in this case is the {area}, Auth is the {controller} and SignIn is the {action}.


Could use a SystemController at the root level of your application, of which the Index() action would simply redirect to /System/Auth/SignIn.