Click to Download C# Example ImageMappedHandlerInCSharp.zip
Click to Download VB.NET Example ImageMappedHandlerInVBNET.zip
Http Handler using ".ashx" file extension and this is very convenient and understandable to all of us. But we can also custom this file extension with our requirement. To make customization in file extension we need to do add class file in "App_Code" folder and this class file implement "IHttpHandler" interface. And also mapping file extension in IIS and add settings in "web.config" file.
This configuration tell the application to show which file extension this handler serves. We can You do this by adding an <httpHandlers> section to the web.config file.
Here is configuration setting :
This settings direct the application to use the "ImageMappedHandler" class to process incoming requests for ImageHandler.img. We can also specify wildcards for the path. By specifying *.img for the path which indicates that we want the application to use the ImageMappedHandler class to process any request with the
.img file extension. By specifying * indicates that we want all requests to the application to be processed using the handler.
Additional Configuration for IIS 7 :
If we run out web application on IIS 7 then we also must add the <handlers> configuration section to the <system.webServer> configuration section in our application’s config file. When adding the handler configuration in this section, we must also include the name attribute.
Configuration for IIS 7 :
Now after doing this settings we can directly call ImageHandler.img from browser and we can get image from that.
Here is example for this.
Click to Download VB.NET Example ImageMappedHandlerInVBNET.zip
Http Handler using ".ashx" file extension and this is very convenient and understandable to all of us. But we can also custom this file extension with our requirement. To make customization in file extension we need to do add class file in "App_Code" folder and this class file implement "IHttpHandler" interface. And also mapping file extension in IIS and add settings in "web.config" file.
This configuration tell the application to show which file extension this handler serves. We can You do this by adding an <httpHandlers> section to the web.config file.
Here is configuration setting :
<system.web> <httpHandlers> <add verb="*" path="ImageHandler.img" type="ImageMappedHandler, App_Code"/> </httpHandlers> </system.web>
This settings direct the application to use the "ImageMappedHandler" class to process incoming requests for ImageHandler.img. We can also specify wildcards for the path. By specifying *.img for the path which indicates that we want the application to use the ImageMappedHandler class to process any request with the
.img file extension. By specifying * indicates that we want all requests to the application to be processed using the handler.
Additional Configuration for IIS 7 :
If we run out web application on IIS 7 then we also must add the <handlers> configuration section to the <system.webServer> configuration section in our application’s config file. When adding the handler configuration in this section, we must also include the name attribute.
Configuration for IIS 7 :
<system.webServer> <handlers> <add name="ImageHandler" verb="*" path="ImageHandler.img" type="ImageMappedHandler, App_Code" /> </handlers> </system.webServer>
Now after doing this settings we can directly call ImageHandler.img from browser and we can get image from that.
Here is example for this.

