How to Set the Default Page in web.config

On most hosted sites the vendor does not allow you to directly make changes to IIS, instead they normally give you some sort of control panel or user interface to do all that you need. The down side is that you normally have to go to each tab or screen make the change and then wait or restart IIS to see the changes. Although this is fine in most cases there are times when you constantly make the same changes to each site you deploy. Until IIS 7 you were hard pressed to do anything other than contact provider to make the changes for you.

Along came IIS 7 with the distributed configuration options. This allows you to make changes to the server without having permission to directly effect IIS. If you put these settings into a web.config file that runs on something less than IIS 7 the server will ignore these setting so you will be fine.

The key to this setting is to place the below xml in web.config.  Most of the time in the web.config file you will have the configuration tag along with other settings (….).  Adding the system.webServer section will allow you to do control the default page without having to go to the control panel, make change, restart IIS (potentially) and then see the settings.  If you are using WebSitePanel you can see the impact by the screen shots below.

<configuration>
...
   <system.webServer>
    <defaultDocument>
        <files>
            <clear /> <!--Removes all other default documents-->
            <add value="default.aspx" />
        </files>
    </defaultDocument>
   </system.webServer>
...
</configuration>

default

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , | Posted under ASP .NET 3.5, ASP .NET 4.0, cPanel Tutorials, DotNet/Windows Hosting | RSS 2.0

Author Spotlight

David Bauernschmidt

David Bauernschmidt

I live in the historical triangle of Virginia where I am married with two daughters. I have spent over 13 years working for a Fortune 500 company in the computer area. I started in VB 6.0 and by the time I ended my employment I was supervising a development team where we built many web applications. When my first daughter was born I wanted to spend more time with her so I left and became a programmer analyst for local government as well as launch my own company. Since then I have grown James River Webs into a profitable web design and application company helping small businesses create a big presence on the internet. As an employee I have created web application used by citizens and other companies. I enjoy fly fishing, and spending time with my family. I also enjoy learning new approaches and development tools when it comes to developing applications.

Leave a Reply

Your email address will not be published. Required fields are marked *


6 × 5 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>