I have an application written in asp.net, and I have some classic asp pages integrated into the site. The site uses Windows authentication. Since I cannot manage .asp pages with roles, I wrote my own HttpModule to check if the user has permission to view these pages, otherwise he will be redirected to the "refused" page. The main problem is that the application should run in "classic mode" on IIS7. My module works in integrated mode, but not in classic mode. Is there a reason this code should not work in classic mode? Thanks in advance.
Here is the code for the module, it is quite simple:
public class MyModule: IHttpModule { public void Init(HttpApplication application) { application.PostAuthenticateRequest += new EventHandler(Application_PostAuthenticateRequest); } void Application_PostAuthenticateRequest(object source, EventArgs e) { HttpApplication app = (HttpApplication)source; HttpContext context = ((HttpApplication)source).Context; if (context.Request.RawUrl.Contains("/protected-subfolder/")) {
Here is the setting in web.config for classic mode (doesn't work):
<configuration> <system.web> <httpModules> <add name="MyModule" type="MyModule" /> </httpModules> </system.web> </configuration>
And setting for integrated mode (work):
<configuration> <system.webServer> <modules> <add name="MyModule" type="MyModule"/> </modules> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> </configuration>
source share