Asp.Net MVC Default Route

I have a default route defined as

routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

      

However, if the user is logged in when they visit the site (this can happen if they checked the "remember me last time I logged in" button). I want them to use a different default route and go straight to the login page.

Is this possible in global.asax or will I need to put some logic in my home controller to redirect on login?

+2


source to share


2 answers


Your best bet is to put this in your home controller. Authentication and return of the appropriate type.



+3


source


I want them to use a different default route
ASP.NET MVC routing


is about routing urls to methods of actions on controllers , not about routing users to locations on your website as the case may be. (Think of routing as a static thing, whereas the others (authorization, redirection, etc.) only apply to the current session.)

It is possible to do se Routing Constraints to achieve what you want, but I don't think you want.

+2


source







All Articles