Set default page inside a folder in asp.net

This post is to learn how to Set default page inside a folder in asp.net. There could be a case when you want to make a page as a default page inside a folder in your asp.net application, So if you enter the path till that folder and don’t specify the file name in path it will point to the default file.

This task is very simple and it just need adding some configuration in the web.config file. But this configuration file is not the configuration file which exist in the root of the application, but you need to place separate web.config file in the folder where you want to set default page.

Lets take an example.
Say if you want to make ‘Default.aspx’ as your default file which exist in the ‘app’ folder inside your web application.

How to do that?

Steps:
1. Add a web.config file inside the folder where you want to set default page.
in above example your folder name is ‘app’ and the file name that we want to make default is ‘Default.aspx’ that is inside
the ‘app’ folder.

Web.config content
————————

<?xml version="1.0"?>
<configuration>
   <system.webServer>
        <defaultDocument enabled="true">
            <files>
               <clear/>
               <add value="Default.aspx"/>
            </files>
        </defaultDocument>
  </system.webServer>
</configuration>


Now, when you enter the url till the folder
www.domain.com/app

this will point to the below path
www.domain.com/app/Default.aspx

it’s done. Cheers..!!