Search code examples
c#asp.netweb-configurl-mapping

How to make home page as default page in asp.net


How can i set default home page in asp web.config file.
i have already written this code :

<urlMappings>
  <add url="/" mappedUrl="Home.aspx"/>
  <add url="Default.aspx" mappedUrl="Home.aspx"/>
</urlMappings>     

and also tried this

<defaultDocument>
  <files>
    <add value="Home.aspx" />
  </files>
</defaultDocument>

but i guess its not working. when i type www.example.com it says directory listing is disabled, but does not redirect to www.example/Home.aspx.

I dont want to enable directory listing but if someone types www.example.com he should be send to www.example.com/Home.aspx


Solution

  • Change in your webconfig for iis 7.

    <system.webServer>
          <defaultDocument>
            <files>
              <clear />
              <add value="CreateThing.aspx" />
            </files>
          </defaultDocument>
        </system.webServer>
    

    Take a look for this post :Set Default Page in Asp.net