在 ASP.NET MVC 3 中实现访问控制
我正在 ASP.NET MVC 3 中编写一个基于角色的应用程序。显然,根据用户所处的角色,将取决于他们有权访问哪些页面或功能。我不太确定在 MVC 应用程序中实现此功能的最佳位置或方法。任何信息或某些资源的指向将不胜感激。
提前致谢。
I'm writing a role based application in ASP.NET MVC 3. Obviously, depending on the role the user is in, will depend what pages or functions they have access to. I'm not really certain the best place, or way to implement this in an MVC application. Any information or points to certain resources would be appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想实现自己的会员系统,那么您可以按照以下步骤操作:
AuthenticateRequest
事件FormsAuthentication
类为您创建、加密和解密 cookie。Authentication Cookie
并发送给客户端。If you want to implement your own membership system, then you can follow these steps:
AuthenticateRequest
eventFormsAuthentication
class to create, encrypt and decrypt cookies for you.HttpContext.Current.Items
as a key/value pair. This way, you can use it anywhere you want.Authentication Cookie
and send it to the client.Membership Provider 内置于 .NET 中,可以从 MVC3 中使用。我链接到的帖子概述了如何使用 .NET 框架附带的默认实现,可以 创建您自己的,但我建议首先熟悉默认值。
The Membership Provider is built into .NET and can be used from MVC3. The post I linked to is an overview how to use the default implementation that ships with the .NET framework, it's possible to create your own but I suggest getting familiar with the default first.