I am having problems trying to map an HttpHandler in the web.config.
This is the relevant config bit:
<httpHandlers>
<add verb="*" path="*.hndlr" type="MyAssembly.MyHandler, MyAssembly" validate="false" />
</httpHandlers>
When I navigate to http://localhost/myApp/whatever.hndlr
I am getting a server error 404 (not found).
It's the 1st time I am hooking up an HttpHandler so I might be missing something - any help appreciated!
UPDATE:
I managed to get it working using both answers so far - who's able to exaplin why it works gets the answer marked!
This is my config (won't work if Don't have both - I am running IIS7 in classic mode)
System.web:
<httpHandlers>
<add verb="*" path="*MyHandler.hndlr" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false"/>
</httpHandlers>
System.webserver:
<handlers>
<add name="MyHandler" verb="*" path="*MyHandler.hndlr" type="MyAssembly.MyAssemblyHandler, MyAssembly" validate="false" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
None of the previous answers worked for me.
I'm using
IIS 8.5, .Net v4.0, Integrated
, and was still getting a 404 with the following handler config:I enabled tracing and found the following :
As you can see it looks like it had correctly picked up the request using my custom HttpHandler
testEmail
but MVC had stolen it.I opened my route definitions in
RouteConfig.cs
and found that adding:I got it to ignore requests meant for my Handler.
Hope this helps someone - I was tearing my hair out!
i am using IIS7, the solution is:
in section
and section
Just as a guide for those stuck with this problem I found the crucial attribute to be..
I originally followed a Microsoft example to set this up and they had it as
which just kept giving me 404 errors. My HTTPHandler is returning graphics.
Hope this helps :)
Hopefully my solution will help others. On a server move from IIS6 to 7.5, both .Net 4.0 Integrated, I had a Captcha control that quit working. It turns out that removing this attribute
preCondition="integratedMode,runtimeVersionv2.0"
from the<add>
node in<system.webserver><handlers>
resolved the issue.What is the extension of your handler? If you are using a custom extension like .hndlr you may also need to add a ScriptMap in IIS and point it to the ASP.NET runtime so that IIS can forward the request to the correct processor.
Then in your web.config you will need to register the handler in the appropriate section as described in the other answer.
Are you using IIS7, if so is the application pool running in classic or pipelined mode? If it is IIS7 in pipelined mode then the handler reference needs to go into the following section
rather than in the following section.