删除ASP.NET/IIS 7应用程序中特定路径的HttpModule?

soc*_*dad 6 asp.net iis-7

最简洁的是,我的问题是在IIS 7集成模式下运行的ASP.NET 4.0应用程序是否应该能够遵循我的Web.config文件的这一部分:

  <location path="auth/windows">
    <system.webServer>
      <modules>
        <remove name="FormsAuthentication"/>
      </modules>
    </system.webServer>
  </location>
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用混合模式身份验证(Windows和Forms - 我知道关于该主题还有其他问题).使用IIS管理器,我已禁用匿名身份验证到auth/windows/winauth.aspx,它位于上面的位置路径中.我将失败的请求跟踪设置为跟踪各种HTTP状态代码,包括302s.

当我请求winauth.aspx页面时,返回302 HTTP状态代码.如果我查看请求跟踪,我可以看到401(未授权)最初是由AnonymousAuthenticationModule生成的.但是,FormsAuthenticationModule将其转换为302,这是浏览器看到的.因此,似乎我尝试从该管道中的页面管道中删除该模块不起作用.但我没有在任何地方看到任何投诉(事件查看器,黄页死亡等),这表明它是无效的配置.我希望401返回到浏览器,这可能包括一个适当的WWW-Authenticate标头.

其他几点:a)我<authentication mode="Forms">在我的Web.config中有,这就是302重定向到的内容; b)我得到了我试图从inetserv\config\applicationHost.config文件中删除的模块的"名称"; c)我在Web.config文件中有这个元素:<modules runAllManagedModulesForAllRequests="false">.

有没有人以这种方式去除模块?

Joh*_*ers 0

不删除该模块,而是删除该路径的表单身份验证怎么样?

  <location path="auth/windows"> 
    <system.Web> 
        <authentication mode="None"/> 
    </system.Web> 
  </location> 
Run Code Online (Sandbox Code Playgroud)