Search code examples
c#asp.netauthorizationhttpmodule

Programmatically determine if path is restricted


I am creating an HttpModule in ASP.NET 2. The module needs to perform a different logic based on whether or not the requested path is public or protected. The web.config sets authorization with the <system.web><authorization> tag and several <location> tags.

Is there a way for the HttpModule to figure out if the path of the current request is protected or not? I don't want to hard code the values in the code.


Solution

  • If your using standard authentication/authorization then you can use CheckUrlAccessForPrincipal.

    UrlAuthorizationModule.CheckUrlAccessForPrincipal(virtualPath, user, verb);