转换web.config时,如何插入web.config节点作为父节点的第一个子节点?所以我有
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Foo" stopProcessing="true">
...
</rule>
<rule name="Bar" stopProcessing="true">
...
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我想插入另一条规则作为第一条规则。 web.Release.config中的以下代码仅将其添加到最后。
<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>
答案 0 :(得分:19)
这就是诀窍
<rule name="Blah" stopProcessing="true"
xdt:Transform="InsertBefore(/configuration/system.webServer/rewrite/rules/rule)">
...
</rule>