How to access datas based on user roles in asp.net ?
For example : i have two admins (admin1, admin2) .
In the frontend ,admin1 has full access to datas(view,add,edit,delete all datas)
开发者_运维知识库while admin2 has limited access to datas(view,add,edit,delete certain datas alone and not all datas)
thank you
Just use the Roles.IsUserInRole method to qualify whether a user is in a role or not then show the corresponding data.
Roles.IsUserInRole(<USERNAME>, <ROLE>)
You could use the code Ira Rainey posted to toggle control using code or you could use a LoginView Control.
Check the Displaying Role-Specific Markup With the LoginView Control section of this article (go down the page) to get an overview.
精彩评论