Search code examples
asp.netasp.net-identityidentityserver3

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. By the way, I am doing it in web form at the moment.

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.

Write my own custom code or there is a Microsoft built-in class to do this?

Regards, Steve


Solution

  • 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.

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

    If you need to go beyond that you will need to build your own code to suit your needs.