基于角色的访问

发布于 2024-08-24 10:08:22 字数 118 浏览 1 评论 0原文

我正在使用 asp.net 和 c#。我有 5 个角色,例如经理、超级用户、团队领导等。根据角色,用户将数据视为仅限于他,只有超级用户可以操作该数据等。我正在使用表单身份验证。任何人都可以提供代码或任何形式的帮助。 请帮忙

i am using asp.net with c# .I have 5 roles such as manager,super user, team leader etc .Depending on the role the user sees the data as restricted to him ,only super user can manipulate that data etc.I am using forms authentication.Can anyone provide the code or any form of help is appriciated.
Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我三岁 2024-08-31 10:08:22

假设您有一个名为 EditData.aspx 的页面,允许用户编辑某些数据,但您只希望属于某些角色的用户访问该页面,您可以将以下内容添加到 web.config 中:

<configuration>
   <location path="EditData.aspx">
      <system.web>
         <authorization>
            <deny users="*"/>
            <allow roles="Manager, SuperUser"/>
         </authorization>
      </system.web>
   </location>
</configuration>

Say you have a page that allows a user to edit some data, called EditData.aspx, but you only want users belonging to certain roles to access that page, you would add the following to your web.config:

<configuration>
   <location path="EditData.aspx">
      <system.web>
         <authorization>
            <deny users="*"/>
            <allow roles="Manager, SuperUser"/>
         </authorization>
      </system.web>
   </location>
</configuration>
执着的年纪 2024-08-31 10:08:22

开始使用 Beer House 入门套件,这是一个如何使用会员资格、角色、个人资料、个性化等提供程序以及一些良好的可重用代码的完整示例。

Get started with the Beer House starter kit which is a complete example of how membership, role, profile, personalization etc providers are used along with some good re-usable code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文