Removing HttpModule for specific path in ASP.NET / IIS 7 application?
Posted
by soccerdad
on Server Fault
See other posts from Server Fault
or by soccerdad
Published on 2010-06-17T23:03:45Z
Indexed on
2010/06/17
23:13 UTC
Read the original article
Hit count: 205
iis7
Most succinctly, my question is whether an ASP.NET 4.0 app running under IIS 7 integrated mode should be able to honor this portion of my Web.config file:
<location path="auth/windows">
<system.webServer>
<modules>
<remove name="FormsAuthentication"/>
</modules>
</system.webServer>
</location>
I'm experimenting with mixed mode authentication (Windows and Forms). Using IIS Manager, I've disabled Anonymous authentication to auth/windows/winauth.aspx, which is within the location path above. I have Failed Request Tracing set up to trace various HTTP status codes, including 302s.
When I request the winauth.aspx page, a 302 HTTP status code is returned. If I look at the request trace, I can see that a 401 (unauthorized) was originally generated by the AnonymousAuthenticationModule. However, the FormsAuthenticationModule converts that to a 302, which is what the browser sees. So it seems as though my attempt to remove that module from the pipeline for pages in that path isn't working. But I'm not seeing any complaints anywhere (event viewer, yellow pages of death, etc.) that would indicate it's an invalid configuration. I want the 401 returned to the browser, which presumably would include an appropriate WWW-Authenticate header.
A few other points: a) I do have <authentication mode="Forms">
in my Web.config, and that is what the 302 redirects to; b) I got the "name" of the module I'm trying to remove from the inetserv\config\applicationHost.config file; c) I have this element in my Web.config file: <modules runAllManagedModulesForAllRequests="false">
; d) I tried a <location>
element for the path in which I set the authentication mode to "None", but that gave a yellow exception page that the property can't be set below the application level.
Anyone had any luck removing modules in this fashion?
© Server Fault or respective owner