我有2个不同的服务器,如开发和生产。所以我尝试了更改动态连接字符串和一些键。我喜欢这个2 web.config文件。
1) Web.Develop.Config
2) Web.Production.Config
现在在我的web.config文件中,我喜欢这个连接字符串和一些键。
<connectionStrings>
<add name="DefaultConnection" connectionString="localhost" />
</connectionStrings>
<add key="Email" value="[email protected]" />
现在在我的web.Develop.config文件中,像这样设置连接字符串和一些键。
<add name="DefaultConnection"
connectionString="develop"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add key="Email" value="[email protected]" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
现在在我的web.Producation.config文件中,像这样设置连接字符串和一些键。
<add name="DefaultConnection"
connectionString="producation"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add key="Email" value="[email protected]" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
所以现在我已经使用在线VSTS进行构建和发布,并且在开发服务器上使用连接字符串中的web.config文件不会更改。并在此处显示如下。
<connectionStrings>
<add name="DefaultConnection" connectionString="$(ReplacableToken_develop-
Web.config Connection String_0)" />
</connectionStrings>
但是,我的电子邮件已更改,我正在为开发服务器获取正确的电子邮件地址。
所以任何人都知道如何解决web.config文件中动态更改的连接字符串的问题?请帮我。
尝试以下方法
<add name="DefaultConnection"
connectionString="develop connection string"
xdt:Transform="Replace" xdt:Locator="Condition(@name='DefaultConnection')"/>