How to register an IHttpHandler as a default document

92 views Asked by At

I have an IHttpHandler registered in web.config like so:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <!-- These are the HTTP handler registrations for IIS7+ in Integrated Pipeline mode; that is the current recommended mode for all deployments. -->
    <handlers>
      <add name="LaunchHandler" verb="GET,POST" path="launch.axd" preCondition="integratedMode" type="Foo.LaunchRequestHandler, Foo" />
      ...
    </handlers>
</system.webServer>

This works fine if I navigate to /launch.axd directly, but I want this handler to run for the root path.

My initial approach was to create a default.aspx page that redirects to launch.axd, this does work but obviously requires an extra roundtrip to the browser.

As an alternative to using a default.aspx page I tried adding launch.axd as a Default Document, like so:

<defaultDocument>
    <files>
        <add value="launch.axd"/>
        ...
    </files>
</defaultDocument>

However this does not work. Navigating to to root path returns this message:

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

I.e. the request is being handled by DirectoryListingModule.

Any ideas? Can a handler that is not backed by a file (aspx, ashx) be registered as a default document?

0

There are 0 answers