I have a value stored in my web.config file that I would like to change when the site is published. I want to change it from TEST to LIVE.
<appSettings> <add key="RequestMode" value="TEST" /> // other keys here </appSettings>
Is this possible using web.config transformation syntax? If so, how?
Thanks.
A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.
If you go to Build > Configuration Manager... and select the Active solution configuration drop-down you can add new build names. Afterward you can right-click your web. config and Add Config Transform , which asks no questions and just creates one transform for each build.
The machine. config file file is at the highest level in the configuration hierarchy while Web. config file is to override the settings from the machine. config file.
Yes this is possible with transformation syntax. This transformation should do the trick:
<?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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With