May 1, 2014

Most (if not all) web sites will have a default start page for example, default.aspx, index.aspx, home.aspx, etc. The default start page kicks in when someone goes to a url that does not refer to the page (no file extension) but possibly to a folder - for example, example.com/ or example.com/test . Without the default page, the user will be shown or not shown the directory listing page depending on the IIS configuration. For security reasons, it's better not to show end users the directory listing page. I once saw an application with directory listing that was showing the log folder and files.

To configure the default page, it can be configured from both IIS and asp.net. In this post, I will show how to configure from asp.net. Within the web.config file, place the default document options correctly as shown below.

web.config
  1. <system.webServer>
  2.   <defaultDocument enabled="true">
  3.     <files>
  4.       <clear/>
  5.       <!--first preference-->
  6.       <add value="default.aspx"/>
  7.       <!--show second preference if first file is not found-->
  8.       <add value="home.aspx"/>
  9.     </files>
  10.   </defaultDocument>

0 comments:

Reference: Shahed Kazi at AspNetify.com