Problems with Web.Config

2

I'm having difficulty using multiple web.config on my system. In my web.config main I have the following configuration:

<configuration>
  <appSettings>
    <add key="BASE_URL" value="/mvc/" />
  </appSettings>
</configuration>

And in my file web.release.config I have the following modification:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="BASE_URL" value="/mvc" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
  </appSettings>
</configuration>

However, when I call the property BASE_URL , it is returning me the value of the main config and not the modifier, even though I use the Release configuration to build the project.

I'm using C # MVC4 in VS2013

    
asked by anonymous 28.08.2014 / 19:49

2 answers

1

There are three Web.config settings:

  • Web.config - Used in any Configuration Manager (Debug / Release) situation while you are running your application directly through Visual Studio.
  • Web.Debug.config - Used for publishing when Configuration Manager is in Debug
  • Web.Release.config - Used for publishing when the Configuration Manager is in Release
So you can achieve three situations where your variables can be changed, I particularly find this advantageous in situations that deal with local addresses, the Web.config setting points to a physical location on my machine (eg C: / Test /), and the others point to their IIS virtual addresses (eg / Debug / Files / for Debug and / Release / Files / for Release).

    
15.09.2014 / 21:55
0

Go to the BUILD Menu - > Configuration Manager.

In the "Active solution configuration" switch, change to release. Make sure that the .config file that will be used is indeed web.config.release.

    
28.08.2014 / 22:14