简体   繁体   English

ASP.NET Identity Manager来管理页面级用户访问

[英]ASP.NET Identity Manager to manage page level user access

Now that I can use ASP.NET Identity Manager to manage the users and Roles. 现在,我可以使用ASP.NET Identity Manager来管理用户和角色。 By the way, I am doing it in web form at the moment. 顺便说一下,我现在正在以Web形式进行操作。

Next what I want to learn is what will be a good way to manage the page based on Roles. 接下来,我想学习的是一种基于角色管理页面的好方法。 Means example Admin Role can access to page1.aspx and page2.aspx while User Role can access to only page3.aspx. 意味着示例“ 管理员角色”可以访问page1.aspx和page2.aspx,而“ 用户角色”只能访问page3.aspx。

Write my own custom code or there is a Microsoft built-in class to do this? 编写我自己的自定义代码,或者有Microsoft内置类可以做到这一点?

Regards, Steve 问候,史蒂夫

For Web Forms and MVC you can add the Authorize attribute to the class or each method for to implement role based permissions on a per page basis. 对于Web窗体和MVC,您可以将Authorize属性添加到类或每个方法中,以实现基于页面的基于角色的权限。

[Authorize(Roles = "User,Admin")]

If you need to go beyond that you will need to build your own code to suit your needs. 如果您需要超越此范围,则需要构建自己的代码以适合您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM