.net Web.config转换添加树
我想在发布时将以下内容添加到web配置中:.net Web.config转换添加树,.net,asp.net-mvc,web-config,webmatrix,web.config-transform,.net,Asp.net Mvc,Web Config,Webmatrix,Web.config Transform,我想在发布时将以下内容添加到web配置中: <system.webServer> <httpProtocol> <customHeaders> <add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains" xdt:Transform="Insert" /> </customHea
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains" xdt:Transform="Insert" />
</customHeaders>
</httpProtocol>
</system.webServer>
然而,这似乎不是正确的方式
是否有更正确的方法在转换上构建元素树?将空的
节点添加到web.config中是有效的,因为转换是插入并尝试删除xmlns=attributes?
<httpProtocol>
<customHeaders>
</customHeaders>
</httpProtocol>
<?xml version="1.0">
<configuration>
<system.webServer>
<httpProtocol />
</system.webServer>
</configuration>
<?xml version="1.0">
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<httpProtocol>
<customHeaders xdt:Transform="Insert">
<add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
<?xml version="1.0">
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>