views:

460

answers:

2

I have the following in my Web.config:

<httpHandlers>
    . . .
    <add verb="GET,HEAD" path="/" type="Vis.Web.BootHandler, Vis" />
</httpHandlers>

That HTTP handler returns a static HTML page, just to see if it works.

Now when I run my web application (which has no Default.aspx or the likes) I get the default directory listing instead. When I change the path to "/foo" it works perfectly fine.

I tried "" for the path, it yields the directory listing as well. Same having it as "/foo" and then adding a URL mapping to for "", "~", "~/" and "/"

How do I handle the web root / override the directory listing with a HTTP handler?

+1  A: 

UPDATED: Regarding comment This can't be done in the development server as it requires a feature of IIS.

ORIGINAL: You need to add a wildcard application mapping to the asp.net DLL so that all requestes (even for directories) are run through the .net runtime and therefore your HTTP Handler.

Check out http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx

for more info

Greg B
Thanks, very helpful. Can it also be done for the built-in web server in Visual Web Developer?
sjmulder
Too bad it doesn't work on the development server then, but at least being able to do it with IIS is a big improvement.
sjmulder
A: 

In addition to what @Greg B said you will need to add a dummy default.aspx page and register your handler using /* path:

<httpHandlers>
    . . .
    <add verb="GET,HEAD" path="/*" type="Vis.Web.BootHandler, Vis" />
</httpHandlers>
Darin Dimitrov