blue18hutthutt
blue18hutthutt

Reputation: 3243

ASP.NET HttpHandler vs IIS handler

I've defined an HTTP Handler and added an entry in my web.config

<add verb="GET" path="TestApp/*" type="TestApp.TestHandler, TestWebApp" />

This works as I would expect EXCEPT when I encounter static resources eg JPG, PNG files

I need my handler to also handle paths like TestApp/logo.gif but it seems like IIS has the StaticHandler registered to intercept these requests

Is there any way for my ASP.NET HttpHandler to have a chance to handle requests for static resources ONLY for the path TestApp/* but letting the IIS StaticHandler handle everything else?

And yes I realize that letting IIS handle static resources with its own handler is faster and more efficient

Upvotes: 0

Views: 1323

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039438

Your handler will intercept those requests if you are running in integrated pipeline mode:

<system.webServer>
    <handlers>
        <add name="TestHandler" path="TestApp/*" verb="GET" type="TestApp.TestHandler, TestWebApp" />
    </handlers>
</system.webServer>

If you are running in Classic Pipeline mode you will have to register an ISAPI filter in IIS in order to make those requests go through the managed handler.

Upvotes: 1

Kenneth
Kenneth

Reputation: 28747

You should add this to your web.config:

<modules runAllManagedModulesForAllRequests="true" />

This will ensure that even requests for static files are being passed through the .net pipeline.

Upvotes: 1

Related Questions