Question

I have a project which has a normal web.config with the following appsettings:

<add key="CachingEnabled" value="true"/>
<add key="IsDeployed" value="true"/>

In my web.debug.config I have tried to overwrite these settings with

<add key="CachingEnabled" value="false" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
<add key="IsDeployed" value="false" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>

And I also put the corresponding values in the web.release.config

However, when I step through my code, these values are still the same as the ones in the main web.config

Do these values only apply if you deploy the site in debug mode or should they work if you are just running the site locally? I am running the site locally through iis rather than by pressing the play button in visual studio if that makes any difference.

Was it helpful?

Solution

These values don't apply to anything, what happens is as part of the publish command VS transforms your default web.config using the rules you have defined in your build-specific web.config (in your case, your debug build config).

A lot of people get confused thinking that these values just automagically work when you build your project, that's not the case. However, if you want this behaviour there is a nice little plugin called SlowCheetah that will do this for you.

It's worth reading up on Web.config File Transformations and How to: Transform Web.config When Deploying a Web Application Project

OTHER TIPS

The web.debug.config or web.release.config are only consumed by web deployment to transform web.config, say "Build deployment package" or "Publish". Regular build/debug doesn't invoke transform.

SlowCheetah may be able to help you: http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top