is there an authorizeattribute equivalent to just standard web forms (not MVC) for .net

Blair Jones picture Blair Jones · Nov 18, 2010 · Viewed 9.1k times · Source

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?

Answer

Klaus Byskov Pedersen picture Klaus Byskov Pedersen · Nov 18, 2010

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

<configuration>
  <system.web>
    <authorization>
      <allow roles="domainname\Managers" />
      <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