2

I have my default route defined like this

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 ticked the remember me button last time the logged in) I want them to take a different default route and go straight to the logged in page.

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

dove
20.8k14 gold badges88 silver badges109 bronze badges
asked Oct 13, 2009 at 8:29

2 Answers 2

3

Best to put this in the home controller. A check if authenticated and return the appropriate view.

answered Oct 13, 2009 at 8:32
Sign up to request clarification or add additional context in comments.

Comments

2

I want them to take a different default route
Routing in ASP.NET MVC is about routing URLs to action methods on controllers, not about routing users to places in your web site depending on the current circumstances. (Think of routing as a static thing, whereas the rest (authorization, redirection, etc) is only applicable to the current session.)

It is possible to use Routing Constraints to achieve what you want, but I don't think that's what you want.

answered Oct 13, 2009 at 8:33

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.