asp.net - How do I register multiple paths for a HttpHandler in IIS7? -


I have a html handler which changes the size of images based on quickstring, so make such a request:

I have given my handler's path to * .jpg, * .gif, * .bmp, * .png Mapped in the form. However, this does not activate the handler if I only make it *. Jpg , then it works.

My question is, do I have to create 4 different mapping entries, one for each image type, or what is a way to combine multiple extensions in one way?

Daniel T's answer:

handler mapping of IIS 7 IIS 7 handler Mapping is different. In IIS 6, you can map your controller to web.config :

  & lt; Configuration & gt; & Lt; System.web & gt; & Lt; HttpHandlers & gt; & Lt; Verb = "gET" path = "* .jpg, * .gif, * .bmp, * .png" type = "YourProject.ImageHandler" /> & Lt; / HttpHandlers & gt; & Lt; /system.web> & Lt; / Configuration & gt;  

This allows you to use multiple routes, comma-delimited. In IIS 7, it is in a separate section:

  & lt; Configuration & gt; & Lt; System.webServer & gt; & Lt; Operators & gt; & Lt; Add name = "ImageHandler for JPG" path = "* .jpg" action = "received" type = "your project.imagehandler" resource type = "file" /> & Lt; Add name = "ImageHandler for GIF" path = "* .gif" action = "received" type = "YourProject.ImageHandler" resourceType = "file" /> & Lt; Add name = "ImageHandler for BMP" path = "* .bmp" action = "received" type = "your project.imagehandler" resource type = "file" /> & Lt; Add name = "ImageHandler for PNG" path = "* .png" action = "received" type = "YourProject.ImageHandler" resourceType = "file" /> & Lt; / Operators & gt; & Lt; /system.webServer> & Lt; / Configuration & gt;  

It does not support multiple paths, so you need to map your handler to each path.

You probably have to mapping it in both places because the internal dev server of Visual Studio uses IIS 6 (or is running in IIS 7 compatibility mode), while the production server is probably using IIS 7 Used to be.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -