Thursday, 3 April 2014

HTTPHandler Error - 404 Not Found

If your Web.Config is like below:
<httpHandlers>
<add verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</httpHandlers>
or
<handlers>
<add name="MyHandler" verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</handlers>
When you navigate to http://myserver/myApp/myhandler.api, if it gives server error 404 Not Found error, it might be the web config settings that might be the issue.
Solution:
If you are using IIS7, check in which mode your application pool is configured (Check the properties of  Application Pool in IIS Manager for Managed Pipeline mode).
1) If your application pool running in Classic mode, then the handler reference need to go into the following section:
<system.web>
<httpHandlers>
</httpHandlers>
</system.web>
example:
<system.web>
<httpHandlers>
<add verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</httpHandlers>
</system.web>
2) If your application pool running in Integrated pipelined mode, then the handler reference need to go into the following section:
<system.webServer>
<handlers>
</handlers>
<system.webServer>
example:
<system.webServer>
<handlers>
<add name="MyHandler" verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</handlers>
<system.webServer>

1 comment:

  1. I have follow above steps for configure website with classic mode but still get the 404 error. I have an handler that use to generate captcha in jpg format. I have following settings in web.config:




    ReplyDelete