I have a HttpHandler that resizes images based on the querystring, so requesting something like:
http://server/image.jpg?width=320&height=240
will give you a resized image that's 320x240.
In the IIS Manager
, under Handler Mappings
, I mapped my handler's path as *.jpg,*.gif,*.bmp,*.png
. However, this doesn't activate the handler. If I change it to just *.jpg
, then it works.
My question is, do I have to create 4 separate mapping entries, one for each image type, or is there some way to combine multiple extensions in one path?
The configuration element registers the custom handler factory by class name and maps the . sample file name extension to that handler. Because you are registering a custom file name extension, you register the handler in both the handlers section and the httpHandlers section.
This file is located in %windir%\Microsoft.NET\Framework\framework_version\CONFIG. ApplicationHost. config. This file is located in %windir%\system32\inetsrv\config.
Daniel T's answer:
Turns out that IIS 7's handler mapping is different than IIS 6's handler mapping. In IIS 6, you can map your handlers like this in web.config
:
<configuration> <system.web> <httpHandlers> <add verb="GET" path="*.jpg,*.gif,*.bmp,*.png" type="YourProject.ImageHandler" /> </httpHandlers> </system.web> </configuration>
It allows you to use multiple paths, comma-delimited. In IIS 7, it's in a different section:
<configuration> <system.webServer> <handlers> <add name="ImageHandler for JPG" path="*.jpg" verb="GET" type="YourProject.ImageHandler" resourceType="File" /> <add name="ImageHandler for GIF" path="*.gif" verb="GET" type="YourProject.ImageHandler" resourceType="File" /> <add name="ImageHandler for BMP" path="*.bmp" verb="GET" type="YourProject.ImageHandler" resourceType="File" /> <add name="ImageHandler for PNG" path="*.png" verb="GET" type="YourProject.ImageHandler" resourceType="File" /> </handlers> </system.webServer> </configuration>
It doesn't support multiple paths, so you need to map your handler for each path.
You'll probably have to end up mapping it in both places because Visual Studio's internal dev server uses IIS 6 (or IIS 7 running in compatibility mode), whereas the production server is probably using IIS 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With