0

在 IIS7 集成模式下,特别是在 ASP.NET MVC 和 .NET4 中,所有模块都针对所有请求运行。runAllManagedModulesForAllRequests="true"。让 runAllManagedModulesForAllRequests="false" 让我头疼,并且对此有太多问题,直到我感到困惑。

因此,为了简单起见,只需让我的模块接受所有请求,包括静态文件,但在像 BeginRequest 这样的模块中,我只想在它不是静态文件的情况下处理。如何在模块中过滤或检查此条件?

4

1 回答 1

5

This doesn't exactly answer your question, but since nobody else has answered, I have what could possibly be part of the solution.

If you split your module into two, one for managed handler requests, and one for everything else, then in your web.config, where you add your "managed handler request" module, you can add the attribute preCondition="managedHandler". So it would look like this:

    <system.webServer>
      <modules>
        <add name="DynamicRequestModule" type="..." preCondition="managedHandler" />
        <add name="StaticRequestModule" type="..." />

Given this configuration, the "DynamicRequestModule" module will execute only when the request is for a resource that has a managed handler.

于 2011-08-10T20:54:06.340 回答