Search code examples
c#visual-studioweb-configweb.config-transform

Visual Studio Web.Config Transform


We have our web.configs transformed nicely.

However, to one of them only, we need to add all of this to the web.config.

Not sure how to add a whole XML node.

system.webServer
<rewrite>
  <rules>
    <rule name="Redirect To HTTPS" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
    </rule>
  </rules>
</rewrite>

Solution

  • Use xdt:Transform="Insert" on the <rewrite> node inside the target transform config file