Removing HttpModule for specific path in ASP.NET / IIS 7 application?

Posted by soccerdad on Stack Overflow See other posts from Stack Overflow or by soccerdad
Published on 2010-06-16T22:31:05Z Indexed on 2010/06/16 22:32 UTC
Read the original article Hit count: 230

Filed under:
|

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 - I know there are other questions on S.O. about the topic). 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 couple of 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.

Anyone had any luck removing modules in this fashion?

Thanks much,

Donnie

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about iis7