我使用 AuthorizeAttribute,我如何知道某个操作已授权给当前用户?
我想自动生成菜单,我如何知道某个操作已授权给当前用户(在视图中)?
I want to generate menu automatically, How can I know an action is authorized to current user(in view)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只需要基本功能,您应该考虑使用角色。
http://www.asp.net/security/tutorials
http://rtur.net/blog/post /2009/06/03/Quick-and-dirty-role-management-in-ASPNET-MVC.aspx
对于更强大但非常耗时的开始,请查看 Rhino Security:
http://ayende.com/Blog/archive/ 2008/01/22/Rhino-Security-Overview-Part-I.aspx
您可以从视图或控制器检查用户是否处于特定角色。
You should look at using roles if you only need basic functionality.
http://www.asp.net/security/tutorials
http://rtur.net/blog/post/2009/06/03/Quick-and-dirty-role-management-in-ASPNET-MVC.aspx
For something more robust, but very time consuming to get started with, look at Rhino Security:
http://ayende.com/Blog/archive/2008/01/22/Rhino-Security-Overview-Part-I.aspx
You can check if the user is in a particular role from the view or the controller.
http ://weblogs.asp.net/rashid/archive/2009/09/06/asp-net-mvc-and-authorization-and-monkey-patching.aspx
http://weblogs.asp.net/rashid/archive/2009/09/06/asp-net-mvc-and-authorization-and-monkey-patching.aspx