【发布时间】:2015-05-09 03:36:22
【问题描述】:
我的 MVC 5 应用程序中有许多不同的 Web.configs 用于不同的环境 - 例如。测试/生产
我有网络转换来更改不同环境的值。例如,我的 web.config 文件中有以下应用设置:
<appSettings>
<add key="DevDisplayPanel" value="true" />
</appSettings>
然后在我的 Web.Test.config 和 Web.Prod.config 中使用 web 转换来更改值,如下所示:
<appSettings>
<add key="DevDisplayPanel"
xdt:Transform="Replace"
xdt:Locator="Match(key)"
value="false" />
<appSettings>
但是,在我的 Web.config 中,我也有自己的自定义部分,位于 <appSettings> 部分之外,如下所示:
<myCustomSection>
<serverList>
<add zone="Zone1" url="https://dev-myurl1.com"/>
<add zone="Zone2" url="https://dev-myurl2.com"/>
<add zone="Zone2" url="https://dev-myurl3.com"/>
</serverList>
</myCustomSection>
我的问题是 - 是否可以进行 Web 转换,以便 Test 和 Prod 如下所示:
测试:
<myCustomSection>
<serverList>
<add zone="Zone1" url="https://test-myurl1.com"/>
<add zone="Zone2" url="https://test-myurl2.com"/>
<add zone="Zone2" url="https://test-myurl3.com"/>
</serverList>
</myCustomSection>
产品:
<myCustomSection>
<serverList>
<add zone="Zone1" url="https://prod-myurl1.com"/>
<add zone="Zone2" url="https://prod-myurl2.com"/>
<add zone="Zone2" url="https://prod-myurl3.com"/>
</serverList>
</myCustomSection>
【问题讨论】:
标签: asp.net asp.net-mvc web-config web.config-transform web-config-transform