How can I prevent certain file types from going through the ASP.NET Pipeline (hitting global.asax, etc.)?
-
IIS 7.5 but I'll need to know for IIS 6 as well. – Brian David Berman Feb 18 '10 at 15:14
-
It should not with IIS6 unless you have wildcard mapping enabled. – mxmissile Feb 18 '10 at 15:50
-
Have you checked your handler mappings in IIS? – womp Feb 18 '10 at 17:34
4 Answers
global.asax is a HttpModule, and it will be called for every request that passes through the ASP.NET engine. Images, for example, do dot pass through ASP.NET engine. They are treated as static files.

- 570
- 4
- 20
-
I have breakpoints in the global.asax being hit when requesting images by themselves in IIS 7.5. – Brian David Berman Feb 18 '10 at 15:47
-
check in IIS handlers section to see if you have mapped images to ASP.NET engine. This is probably the case... – ra00l Feb 18 '10 at 18:36
What mode are you using? Integrated Pipeline or Classic? I think this will affect the answer.
But essentially, you just need to make sure your StaticFiles handler is not mapped to ASP.NET.

- 8,748
- 7
- 41
- 62
Note that if you are using the built-in visual studio web server (you say setting breakpoints), then you might experience subtle differences in behavior. Quoting from What are the (dis)advantages of using Cassini instead of IIS?
Another dis-advantage is that it sends every request through the gloabal asax file which includes all requests for images and stylesheets. This means if you have code in there which does things with the file names, such as a look up, then the auxillary files willget processed too.
-
You forgot the citation for the second paragraph. http://stackoverflow.com/questions/103785/what-are-the-disadvantages-of-using-cassini-instead-of-iis/1237125#1237125 – BoltClock Sep 17 '14 at 16:14
If you are running Home version of Windows and can't install IIS because of that, consider using UltiDev Web Server Pro. It's free, lightweight, and unlike Cassini, it handles static content requests outside of the ASP.NET pipeline.

- 702
- 1
- 6
- 16