views:

86

answers:

2

I'd like to run a discrete chunk of .Net code for each and every request that comes through a certain Web site in IIS. This is completely isolated code -- it doesn't affect anything before or after it -- it logs some information from the request, then ends.

Note that this is not something I can put in Application_OnRequestBegin or some other ASP.Net file because I need this to execute for non .Net files (PDFs, images, etc.). It needs to execute for requests that would normally not hit the .Net framework.

Is an HTTP Module what I'm looking for? I've RTFM'ed quite a bit, but it seems there a number of different ways to manipulate the pipeline, and I'm not quite sure which one I should be using.

+1  A: 

You want to write an ISAPI filter (5.0 terminology), or extension (in 6.0).

cdonner
+3  A: 

You can use an HTTP Module, however, to use it you will need to map all requests to IIS which can be done using a wild card map.. This will have a performance impact because you're going to be forcing all requests through the .net runtime.

You could also write your own ISAPI filter, but I believe you'll have to use C++.

Edit

ASP.Net has a default handler if your doign the wild card mapping you need, make sure you still have this in your web.config in your windows/microsoft.net/framework..../config/ folder:

<httpHandlers>
....
            <add path="*" verb="GET,HEAD,POST" type="System.Web.DefaultHttpHandler" validate="True"/>
</httpHandlers>

You might have also removed the handler in your web's config file. Lastly you could try and add an explicit mapping for the pdf file.

JoshBerke
Wildcarding is fine, but after my code has executed, I want the request to continue on unabated. Meaning, I don't want anything to fail because .Net is trying to parse a PDF file or something.
Deane
Ok let me find you the link there's a way to do this.
JoshBerke