我有一个值存储在我的web.config文件中,我想在网站发布时更改。我想将其从TEST更改为LIVE。
- <appSettings>
- <add key="RequestMode" value="TEST" />
- // other keys here
- </appSettings>
这是否可以使用web.config转换语法?如果是这样,怎么办?
谢谢。
解决方法
是的,这是可以用转换语法。这个转型应该做的诀窍:
- <?xml version="1.0" encoding="utf-8"?>
- <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
- <appSettings>
- <add key="RequestMode" value="LIVE" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
- </appSettings>
- </configuration>