重定向至其他页面,根据自己的角色 [英] Redirect to other page according their roles
问题描述
我需要u人在这里帮助。所以,我的系统上,有2个角色。管理员和用户。我使用的登录控制,使他们能够登录系统。我怎样才能让这两个角色重定向到不同的页面?我使用的会员和形式的认证。我想AP preciate如果你能给予一定的帮助我。谢谢:)
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 :)
推荐答案
处理登录控制OnLoggedIn事件。在这种情况下,确定当前用户的角色。可以做如下(LoginUser的再presents您的登录控制):
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);
<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.getroles%28v=vs.100%29.aspx\" rel=\"nofollow\">http://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.getroles%28v=vs.100%29.aspx
然后使用Response.Redirect的基础作用,将它们发送到正确的目的地。
Then use Response.Redirect based on the role to send them to the correct destination.
这篇关于重定向至其他页面,根据自己的角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!