Can't stop firing ASP.NET Module for static content

前端 未结 1 1001
小蘑菇
小蘑菇 2021-02-09 13:01

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:

&         


        
相关标签:
1条回答
  • 2021-02-09 13:40

    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.

    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.

    Finally, runAllManagedModulesForAllRequests="true" is used to override preCondition="managedHandler" so all of them get fired.

    There is more info available at:
    http://www.iis.net/learn/get-started/introduction-to-iis/iis-modules-overview#Precondition

    0 讨论(0)
提交回复
热议问题