문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top