I've been strugling with this for one hour and can't find to simple explanation or at least some Microsoft documentation that states this.
I want to understand behaviour of next files:
- Web.config
- Web.Debug.config
- Web.Release.config
- Web.Staging.config (I created this using Right click on Web.config -> Add Config Transform)
I added next appSetting in Web.config file:
<configuration>
..
<appSettings>
<add key="DevDisplayPanel" value="default value" />
</appSettings>
..
</configuration>
In my Web.Debug.config I changed DevDisplayPanel to this:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="DevDisplayPanel"
xdt:Transform="Replace"
xdt:Locator="Match(key)"
value="Debug mode" />
</appSettings>
</configuration>
I displayed the appSettings item like this:
ViewBag.Test = System.Configuration.ConfigurationManager.AppSettings["DevDisplayPanel"];
I understood that if I run Debug -> Start Debugging in Visual Studio that DevDisplayPanel setting will be read from Web.Debug.config. I can't find a Microsoft documentation stating this.
I tried to run my web application using Debug, Release and Staging solution configuration but they all show DevDisplayPanel value from file Web.config.
Where do files Web.Debug|Release|MyConfiguraton.config come into play. What have I missed and most importantly again this behaviour should be noted in bold somewhere in the docs!!