Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem mapping HttpHandler --> HTTP Error 404 Not Found

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 explain why it works gets the answer marked!

This is my config (won't work if you 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>
like image 985
JohnIdol Avatar asked May 18 '10 15:05

JohnIdol


2 Answers

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

<system.webServer>
    <handlers>
    </handlers>
<system.webServer>

rather than in the following section.

<system.web>
    <httpHandlers>
    </httpHandlers>
</system.web>
like image 60
Ben Robinson Avatar answered Oct 06 '22 06:10

Ben Robinson


Just as a guide for those stuck with this problem I found the crucial attribute to be..

resourceType="Unspecified"

I originally followed a Microsoft example to set this up and they had it as

resourceType="File"

which just kept giving me 404 errors. My HTTPHandler is returning graphics.

Hope this helps :)

like image 43
CResults Avatar answered Oct 06 '22 07:10

CResults