Question

I wrote a dynamic image resizer as a HttpHandler. It's automatically called on anything with an image extension, so for example:

http://www.mysite.com/picture.jpg?width=200&height=100

will run the handler and return a thumbnail image with the proper response headers. However, I want the handler to let a request 'pass through' if it's called without a querystring:

http://www.mysite.com/picture.jpg

I want this to return the image with the header information like it would be if it didn't run it through the handler. Is this possible without having to manually code in the header information (which involves opening filestreams to read data such as last written date), or do I have to convert my handler to a HTTPModule instead?

Was it helpful?

Solution

A handler has to "handle" the request. It's the end of the chain. You either need to make it an HttpModule, or you need to serve the image yourself, whether or not you resize it.

OTHER TIPS

Couldn't you just adjust your handler to account for this case? You could just make sure there are no query string parameters and just map the request path to disk and return the image directly by opening it and just write it to the output stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top