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?
I've tried:
If HttpContext.Current.Response.ContentType = "text/html" Then
'Not an image?
End If
But ContentType IS "text/html" on an image request inside the httpModule.
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.
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)...
Member
65 Points
894 Posts
Detecting an image in an httpModule
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?
I've tried:
But ContentType IS "text/html" on an image request inside the httpModule.
Ideas?
Participant
1471 Points
442 Posts
ASPInsiders
MVP
Re: Detecting an image in an 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 ---
West Wind Technologies
Making waves on the Web
weblog.west-wind.com
Check out: Markdown Monster
Member
65 Points
894 Posts
Re: Detecting an image in an httpModule
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)...