Posted by Michael Heliso
It's been a while since I had to write custom HTTP handlers. One of my current projects required resourses to be provided using a custom HTTP handler. That was quite an easy job and for sure you will find many detailed posts related to HTTP handlers development under .NET. The only thing which gave me some headaches was the deployment of such a handler. There is a different approach under IIS7 (integrated mode) compared with IIS6. Here are the required steps:
1. From IIS management interface create a web application which points to the root folder where you have your HTTP handler. Please note that the actual DLL (assembly) should be located under root directory in a "bin" folder (e.g.: C:\MyHandlerRootFolder\bin\myhandler.dll). Please be sure that you are configuring your web application to run under the correct application pool. So if your HTTP handler assembly is compiled with .NET 4.0 be sure that the web application is configured to run under ASP.NET v4.0 application pool. My issue was caused by a missconfiguration of the HTTP handler. Due to this, everyt time when I was trying to access the handler I was getting the following exception: "Could not load type 'MyHandlerClass'"
2. In the web.config file which should be hosted in your web application root folder add (or change if it is the case) the following configuration elements:
<system.webServer> <handlers> <add verb="*" path="*.myextension" name="MyHttpHandler" type=" MyFullNamespace.MyHandlerClass, MyFullHttpHandlerAssemblyName"/> </handlers> </system.webServer>
That's all, now you handler should be up and running.