Last post Nov 15, 2011 09:20 AM by ojm37
Oct 27, 2011 01:33 PM|ojm37|LINK
I have an httpModule that modifies the output stream of aspx page-requests. However, now with IIS7.5 Integrated mode, it's also modifying the output stream of images. Is there a way to tell, without the brute-force "check-file-extension" method, to determine
if the output is an image?
If HttpContext.Current.Response.ContentType = "text/html" Then
'Not an image?
But ContentType IS "text/html" on an image request inside the httpModule.
Nov 14, 2011 10:52 PM|rstrahl|LINK
Nope you need the brute force approach.
The problem with checking for Response.ContentType is that the content type is probably not set yet by the handler responsible for serving the file (most likely the StaticFileHandler). So unless you're using a post handler Application/Module event the ContentType
will still be at the default which is text/html.
Extension checking is pretty efficient though (use Path.GetExtension() ) to make this easy.
+++ Rick ---
Nov 15, 2011 09:20 AM|ojm37|LINK
Thanks. I was hoping there was some kind of Request.Type that would tell me if the request was static (image file, css, js, etc) or active (aspx, asmx, axd, etc)...