views:

64

answers:

2

Hello all,

I am trying to implement a custom HTTPModule for ASP.NET. I have a very simple html page with an image in it and an HTTPModule that hooks into the BeginRequest event. When I debug with Visual Studio's dev web server, my module is called twice: one for the initial page request, then once for the image request. This is what I expected. However, when I deploy my application to IIS, the module is only being called once for the page request. I don't understand why. Any ideas? Thanks.

A: 

First thing to check: is the server actually being contacted at all for the image? Is it in the client cache?

Second thing to check: is it being cached server-side perhaps?

Try loading the URL of the image itself directly in your browser... and maybe add something like ?foo=bar at the end to perform some primitive cache-busting.

Jon Skeet
Yes, the server is contacted. I do a page refresh, have Fiddler open and see the request go through.I hit the image directly and it still did not call the custom module. I tried the ?foo=bar and no dice - I even did an IIS reset.
skazzaks
As Jon already recomended, try to clear the cache before you call the webserver.
Yves M.
+3  A: 

I'm guessing that you are using IIS6 or IIS7 with Classic Managed Pipeline Mode. In that case, your ASP.NET application only receives requests that are mapped to isapi.dll. Typically, these include requests with the following extensions: aspx, ashx, asmx, ... Take a look here for some more info.

Requests for other extensions are handled directly by IIS so they never arrive at your HTTP module (which runs as a part of the ISAPI extension).

In IIS7 and later Microsoft has integrated the pipeline into IIS. This means that all requests pass along the entire ASP.NET pipeline.

Another possibility is that your image is cached somewhere, as suggested by Jon.

Ronald Wildenberg
@skazzaks: To clear this even further: Your development machine is either running Cassini or IIS7 integrated mode and your production server either IIS6 or IIS7 classic mode.
Robert Koritnik