Search code examples
c#asp.netweb-configslowcheetah

Web.config and different configurations in different projects missmatch


I'm using this code (in my DAL project):

ConfigurationManager.AppSettings["server"]

to access appsettings section in web.config file (from web project):

<appSettings>
<add key="server" value="server.name.com"/>
<add key="database" value="databasename"/>
</appSettings>

and in a Web.Debug.config I'm using a following transformation

<add key="server" value="MY-LAPTOP"
     xdt:Locator="Match(key)" xdt:Transform="Replace"/>

after that when I start application the config file isn't transformed. First line of code returns the nontransformed infromation. What's wrong with the code? What am i missing?

I have tried to publish it and when I check config file everything is ok like it is ment to be.


Solution

  • The web.config transformation is only perform during the publish process. You can still enable it on every build, when you it F5, see

    It's an MSBuild task to add.