是否有一个相当于.net 的标准 Web 表单(不是 MVC)的授权属性 [英] is there an authorizeattribute equivalent to just standard web forms (not MVC) for .net

查看:12
本文介绍了是否有一个相当于.net 的标准 Web 表单(不是 MVC)的授权属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个将使用 Windows 角色提供程序的项目,我想将功能限制到某些 AD 组.

使用 MVC,我可以在我的操作方法上方使用 AuthorizeAttribute 并相应地重定向.对于不使用 MVC 的标准 Web 表单应用程序 (.NET 3.5),我可以做类似的事情吗?

解决方案

您可以在 web.config 中使用授权元素进行设置.

<预><代码><配置><system.web><授权><allow roles="domainnameManagers"/><deny users="*"/></授权></system.web></配置>

当使用 时,域组基本上被转换为角色.您可以在 MSDN 上阅读更多相关信息

I'm working on a project that will use windows role providers and I want to limit functionality to certain AD groups.

With MVC, I could use an AuthorizeAttribute above my action methods and redirect accordingly. Is there something similar I can do for a standard web forms application (.NET 3.5) that doesn't use MVC?

解决方案

You can set this up in web.config with the authorization element.

<configuration>
  <system.web>
    <authorization>
      <allow roles="domainnameManagers" />
      <deny users="*" />
    </authorization>
  </system.web>
</configuration>

Basically domain groups are translated into roles when using <authentication mode="Windows" />. You can read more about it on MSDN

这篇关于是否有一个相当于.net 的标准 Web 表单(不是 MVC)的授权属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆