简体   繁体   中英

HTTPModule Only Getting Called Once Per Page

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM