0

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.

Jakob Gade
  • 12,319
  • 15
  • 70
  • 118
  • 1
    Just check that IIS, under `Properties`->`Home Directory`->`Configuration` has the 'ashx' extension mapped appropriately ... – Noon Silk Aug 25 '09 at 03:46

2 Answers2

3

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
  • 17,302
  • 14
  • 89
  • 134
0

If you are using IIS7 but still want to keep your old IIS 6 config files. By setting the Application pool to run in "Classic" mode, the handler will work again.

Not recommended, but sometimes this is a quick and good enough fix.