views:

172

answers:

1

I wrote a tiny HttpHandler, which works beautifully on my machine. However, once it was deployed to our staging server, requesting it gave an 404. I usually prefer configuring HttpHandlers in web.config, but this apparently didn’t work on the server: I fixed it by creating an .ashx file containing just the reference to my HttpHandler.

The .ashx file:

<% @ WebHandler class="MyNamespace.MyProject.MyHttpHandler" %>

The web.config setting:

<httpHandlers>
  <add verb="GET" path="myhandler.ashx" type="MyNamespace.MyProject.MyHttpHandler"/>
</httpHandlers>

I assume the problem is caused by the server using a "special" port (888, don’t ask why) for the website. Can it be something else, what could I be missing?

Why am I seeing this behavior on the server? The HttpHandler runs fine on my local machine with configuration just in web.config, and here it’s also served from a “random” port, i.e. http://localhost:61229/myhandler.ashx.

+2  A: 

It sure sounds like the web.config setting is not being found.

Is this IIS 7 by any chance? In that case make sure you're putting the handler in the <system.webServer> and its <handlers> section.

Rick Strahl
Excellent, lesson of the day: I didn't know HttpHandlers had to be set up in a different section on IIS7. Thanks! :)
Jakob Gade
And there's even a nifty tool in IIS to configure it!
Jakob Gade