不能停止射击ASP.NET模块静态内容 [英] Can't stop firing ASP.NET Module for static content
问题描述
我在ASP.NET MVC应用程序的模块。该模块工作正常,但它发射的每类型的文件,包括即使我有静态内容:
I have a module in an ASP.NET MVC application. The module is working fine, but it's firing for every type of file including static content even though I have:
<modules runAllManagedModulesForAllRequests="false">
<add name="MyModule" ... / >
</modules>
模块挂钩的AcquireRequestState和PostRequestHandlerExecute事件,并都显示静态内容射击(.htm和的.css,.PNG等)。
The module hooks AcquireRequestState and PostRequestHandlerExecute events and both show static content firing (.htm, .css, .png etc.).
我是IM pression的runAllManagedModulesForAllRequests =假应该保持模块从射击non-ASP.NET下的内容。
I was under the impression that runAllManagedModulesForAllRequests="false" should keep modules from firing on non-ASP.NET content.
要澄清:
我可以:设置preCondition =managedHandler是这样的:
I can set preCondition="managedHandler" like this:
<add name="MyModule" type="MyApp.MyModule" preCondition="managedHandler" />
和让我的模块只火管理的要求。
and get my module to fire only managed requests.
不过,我试图理解为什么在一般的IIS管道发射托管模块命中为每个请求。我觉得这个用在旧版本工作得很好,其中,除非runAllManagedModulesForAllRequests =真这不是射击非托管的内容到ASP.NET模块。
However, I'm trying to understand why the IIS pipeline in general is firing managed module hits for every request. I think this used to work just fine in older versions where unless runAllManagedModulesForAllRequests="true" it wasn't firing unmanaged content into ASP.NET modules.
在Windows 8 64位模式下运行的IIS8,集成管道模式。
Running on IIS8 on Windows 8 64 bit mode, with integrated pipeline mode.
更新:
一些研究之后事实证明,符合下列条件:
After some more research it turns out that the following is true:
- 如果runAllManagedModulesForAllRequests =真的所有模块 - 不管他们的preCondition属性上的所有要求设置火灾。这也适用于Application_XXXX事件在HttpApplication的实施
- runAllManagedModulesForAllRequests =false的无保留非托管请求击中模块的作用,除非的preCondition =managedHandler设置
- runAllManagedModulesForAllRequests =false的确实影响Application_XXXX事件,造成这些事件只火管理的要求即可。 IOW,Application_XXXX的行为就好像模块实现了preCondition =managedHandler
- if runAllManagedModulesForAllRequests="true" all modules - regardless of their preCondition attribute setting fire on all requests. This also true for Application_XXXX events implement on the HttpApplication
- runAllManagedModulesForAllRequests="false" has no effect of keeping unmanaged requests from hitting modules, unless preCondition="managedHandler" is set
- runAllManagedModulesForAllRequests="false" does affect Application_XXXX events, causing those events to only fire on managed requests then. IOW, Application_XXXX behaves as if the 'module' implementation had a preCondition="managedHandler"
有关更详细的信息我张贴博客条目:
<一href=\"http://www.west-wind.com/weblog/posts/2012/Oct/25/Caveats-with-the-runAllManagedModulesForAllRequests-in-IIS-78\" rel=\"nofollow\">http://www.west-wind.com/weblog/posts/2012/Oct/25/Caveats-with-the-runAllManagedModulesForAllRequests-in-IIS-78
For more detailed information on this I posted a blog entry: http://www.west-wind.com/weblog/posts/2012/Oct/25/Caveats-with-the-runAllManagedModulesForAllRequests-in-IIS-78
推荐答案
在IIS7微软推出了使用托管(.NET)code,而不只是本地code开发模块和处理的新方法。问题是转换之间的请求,托管和本机code是非常昂贵的,所以微软推出了 preCondition =managedHandler
。这标志该模块仅适用于托管内容的请求(的.aspx,的.asmx,...),所以IIS避免触发它的静态内容。
In IIS7 Microsoft introduced a new way of developing modules and handlers by using managed (.NET) code, not just native code. Problem is switching a request between managed and native code is very expensive, so Microsoft introduced the preCondition="managedHandler"
. It flags the module as only available for managed content requests (.aspx, .asmx, ...) so IIS avoids firing it for static content.
现在,你可以有你想要修改的静态内容的要求,如动态缩小JavaScript的情况。您可以使用C#编写模块并将其编译为一个管理模块,但你希望它的静态内容被解雇,所以你根本就没有将其标记为 managedHandler
。
Now, you can have a situation where you want to modify an static content request, such as minifying JavaScript on the fly. You can write the module using C# and compile it as a managed module, but you want it to be fired for static content, so you simply do not mark it as managedHandler
.
最后, runAllManagedModulesForAllRequests =真正的
用于重写 preCondition =managedHandler
因此所有他们被解雇。
Finally, runAllManagedModulesForAllRequests="true"
is used to override preCondition="managedHandler"
so all of them get fired.
有可用的详细信息在:结果
<一href=\"http://www.iis.net/learn/get-started/introduction-to-iis/iis-modules-overview#$p$pcondition\">http://www.iis.net/learn/get-started/introduction-to-iis/iis-modules-overview#$p$pcondition
There is more info available at:
http://www.iis.net/learn/get-started/introduction-to-iis/iis-modules-overview#Precondition
这篇关于不能停止射击ASP.NET模块静态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!