根据角色重定向到其他页面
我需要你们的帮助。所以,在我的系统上,有 2 个角色。管理员和用户。我使用登录控制来使他们能够登录系统。我怎样才能使这两个角色重定向到不同的页面?我正在使用会员资格和表单身份验证。如果您能给我一些帮助,我将不胜感激。谢谢 :)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
处理登录控件的“OnLoggedIn”事件。在这种情况下,确定当前用户的角色。可以按如下方式完成(下面的“LoginUser”代表您的登录控制):
http://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.getroles%28v=vs.100%29.aspx
然后使用 Response.Redirect根据角色将它们发送到正确的目的地。
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):
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.
我现在就明白了。您需要做的第一件事是,转到控件中登录属性的事件,双击loggedIn行,它将引导您进入cs页面。然后,您需要做的是
然后不要忘记将登录控件的目标 URL 设置为您希望用户在登录后重定向的 url
I got it right now. The first thing u need to do is, go to event at the properties of the login in control, the double click at loggedIn row, the it will direct you at cs page. Then, what u need to do is
Then dont forget to set the destination URL of the login control to url that u want user redirect after login
这将根据用户的角色将用户重定向到相应的页面。
谢谢。
This will redirect the user to respective pages based on their roles.
Thanks.
这段代码的工作原理:
This code works: