IIS 7.5 ignoring local HTTP handlers

httphandleriis-7.5web.config

I am trying to serve a simple proxy application for a web service. For this purpose, I have a HTTP Handler that passes on any request to my website to another website configured in the web.config. The proxy has been tested locally and it works perfectly. I have tested it on VS 2012 using IIS Express and on our local server that runs windows server 2008 R2 and IIS 7.5.

Now, I'm trying for days to install this application on our deployment server, but it is to no avail. Every time I try to access the application, it ignores the fact that I registered a handler on the web.config and the StaticFile handler catches the request instead. It kinda looks like it is ignoring my handler registration.

I have already tried clearing ALL the handlers on my application and leaving only the HttpProxy I made, but it still calls StaticFile.

Here's the funny part. By accident, I successfully configured the proxy handler on the root node of IIS. From then on out the handler worked on my application, but it also broke all other applications on the server as it captures all requests and they didn't have the handler DLL installed. So it works when it's inherited, but doesn't when i configure it locally.

Here's my web.config's webServer section:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <add name="ProxyHttpHandler"
           path="*"
           verb="*"
           type="DDProxy.ProxyHttpHandler, DDProxy"
           resourceType="Unspecified"
      />
    </handlers>
</system.webServer>

Basically I'm stumped because it seems like IIS is ignoring the configurations I pass specifically to this one application. Any ideas?

EDIT: Small development here. It seems that when I edit applicationhost.config the configurations pass on to the application (even when i use the "location" to point my application). Still, when I pass the configuration on the web.config I get no such luck. Tried this on with the DirectoryListing.

Best Answer

If the root web site has a web.config with defined http handlers or other system.webserver nodes the application you have underneath may be inheriting its config from the root application.

You can try blocking inheritance on the root config for the location of the http handler:

<location path="." inheritInChildApplications="false">
  <system.webServer>
   ...
  </system.webServer>
</location>

Or using in the child config like so:

<system.webServer>
  <clear/>
  <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
     <add name="ProxyHttpHandler"
       path="*"
       verb="*"
       type="DDProxy.ProxyHttpHandler, DDProxy"
       resourceType="Unspecified"
     />
    </handlers>
</system.webServer>

Now you still might run into an issue if you have any other Httphandlers defined in the system.web node in the root config, so you may want to clear that out in your child config:

<system.web>
   <httpHandlers>
     <clear />
   </httpHandlers>
</system.web>