Transform Default Document attribute from web config in ASP.NET

148 Views Asked by At

How can I transform DefaultDocument in ASP.NET. I was able to transform other tags using Key. But in my Web.config "Key" attribute is not allowed in web config.

Web.Config

<defaultDocument>
      <files>
        <add Key="DefaultDocument" value="Document1.aspx"  />
      </files>
    </defaultDocument>

SecondWeb.config

<system.webServer>
    <defaultDocument>
      <files>
        <add  key="DefaultDocument" value="Document2.aspx"  xdt:Transform="Replace" xdt:Locator="Match(key)"/>
      </files>
    </defaultDocument>
  </system.webServer>
1

There are 1 best solutions below

0
Geyser LaPunk On

You just need to add defaultDocument element to the every config transformation file like this:

<system.webServer>
    <defaultDocument xdt:Transform="Insert">
      <files>
        <clear/>
        <add value="Default.aspx"/>
        <add value="index.html"/>
      </files>
    </defaultDocument>
 </system.webServer>