When transforming the web.config, how do I insert a web.config node as the first child of the parent? So I have
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Foo" stopProcessing="true">
...
</rule>
<rule name="Bar" stopProcessing="true">
...
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
And I want to insert another rule as the first rule. The below code from web.Release.config only adds it to the end.
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<rewrite>
<rules>
<rule name="Blah" stopProcessing="true" xdt:Transform="Insert">
...
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This did the trick
<rule name="Blah" stopProcessing="true"
xdt:Transform="InsertBefore(/configuration/system.webServer/rewrite/rules/rule)">
...
</rule>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With