我有一个HttpModule
非常严格的自定义身份验证。但我希望它只为托管请求运行(而不是静态请求)。
Asp.net MVC 自动为 IIS7 Web 服务器添加配置部分:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="ScriptModule" />
<remove name="UrlRoutingModule" />
<add name="ScriptModule"
preCondition="managedHandler"
type="System.Web.Handlers.ScriptModule,..." />
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,..." />
</modules>
<handlers>
...
</handlers>
</system.webServer>
当我添加我自己的模块时,我也设置了它preCondition="managedHandler"
,但是由于runAllManagedModulesForAllRequests="true"
在父<module>
元素上有我preCondition
被设计忽略(正如我在 MSDN 上阅读的那样)。
当我尝试设置时:
<modules runAllManagedModulesForAllRequests="false">
我得到一个错误。
我还必须设置什么(哪个其他模块)web.config
才能使此设置起作用:
<modules runAllManagedModulesForAllRequests="false">