ASP.NET:检索页面的授权角色
我有一个 ASP.NET 站点,它使用自定义角色提供程序来确定站点不同部分的授权。 我已经在 web.config 中为站点的不同部分配置了授权角色。
如果用户不处于特定角色,我希望能够告知他们需要哪个角色才能访问该网站的该部分,以便可以生成准确的授权请求并将其发送以供批准。
是否有一种简单的方法来测试哪些角色可以访问站点中的给定页面?
I have an ASP.NET site that uses a custom role provider to determine authorisation for different parts of the site. I have configured the authorised roles for different parts of the site in web.config.
If a user is not in a particular role, I'd like to be able to inform them which role they require to be able to access that part of the site, so that an accurate authorisation request can be generated and sent off for approval.
Is there a straightforward way of testing which roles can access a given page in the site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的网站设置,将您的网站构建为每个角色的文件夹可能很实用。 这样您就可以查看 URL 来确定角色。
话虽这么说,我确信有一种方法可以以编程方式找出您在 Location 元素中设置的内容 - 但我不知道,抱歉:)
Depending on your website set-up, it may practical to structure your websites into folders for each role. That way you can look at the URL to determine the role.
That being said I'm sure there's a way to programmatically find out what you set in the Location elements - but I don't know it sorry :)