0

In IIS7 integrated mode, especially in ASP.NET MVC and .NET4, all modules run for all request. runAllManagedModulesForAllRequests="true". making runAllManagedModulesForAllRequests="false" give me headace and too many issue about this until I get confused.

So to make it simple, just let my module accept all request including static file but in the module like BeginRequest, I want to handle only if it is not static file. How to filter or check this condition in module?

1 Answer 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.

Sign up to request clarification or add additional context in comments.

2 Comments

ok, maybe you are right, but I cannot test it right now. I what I do last time, in the BeginRequest I check if the URL contain images, javascript or css file extension to be ignored. Ofcause not a right solution but it works.
But the StaticRequestModule would execute for all requests instead of just for static content so you still need a method to differentiate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.