Different default pages/controllers for every role type - MVC 5

Viewed 4225

So my Q is as following (MVC 5): I got several types of default pages i'd like to start when my app is getting up.

1- for anonymous user

2...5 - for the other user roles which are automatically logged (cookie).

So that's pretty much a simple "if", i know, but meanwhile i was using the User.IsInRole("RoleName") method which cannot be used in RouteConfig.cs.

If it's a simple add of a Using statement, i apologize for the simplicity of the question in advance.

Update: I've managed to do it via some:

if(User.UserInRole("RoleName") return RedirectToAction("ActionName") in my default ActionResault.

Although it's not an elegant solution, nor it defines numerous default pages, but it makes the job done.

3 Answers
Related