Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect to other page according their roles

i need help from u guys here. So, on my system, there are 2 roles. Admin and users. I use login control to enable them to login to the system. How can i make these two roles redirect to different page? I am using membership and form authentication. I would appreciate if you could give some help to me. Thank you :)

like image 493
Who Me Avatar asked Jan 17 '23 09:01

Who Me


1 Answers

Handle the Login controls "OnLoggedIn" event. In this event, determine the current users role. That can be done as follows ("LoginUser" below represents your login control):

string[] userRole = Roles.GetRolesForUser(LoginUser.UserName);

http://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.getroles%28v=vs.100%29.aspx

Then use Response.Redirect based on the role to send them to the correct destination.

like image 92
swannee Avatar answered Feb 01 '23 12:02

swannee