Search code examples
web-applicationsdefaultihttphandler

Set .ashx as start "page" for web application


Is it possible to set an .ashx file as the starting (or default) page for a web application? If so, how is it done?

Edit - Some good suggestions. I have added "Default.ashx" to the IIS Default Documents and "Enabled Default Document" on the website, however, it only displays a directory listing even though I have disabled directory browsing.

Any other suggestions would be appreciated. (IIS Version 5.1)

Edit - Restarted IIS and it works.

Question - May I also ask if it is possible to set the start page to an .ashx from within Visual Studio 2005? I can't seem to debug from within Visual Studio after doing this.

Answer - In the Application Properties a "Start Action" can be selected under the "Web" tab. In fact, it also allows the selection of which Server/Port and Debugger to use. Very cool.


Solution

  • Add your ASHX page and make sure you move it to the top of the list.

    And in IIS7, you can specify it in web.config:

    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="my_default_page.ASHX" />
            </files>
        </defaultDocument>
    </system.webServer>    
    

    More information in this blog post

    EDIT: As @waves discovered, you might need to restart IIS after the configuration.


    To disable directory browsing, uncheck the "Directory Browsing" checkbox:

    .