Reputation: 69
I have been trying to google and change and in the mode of hating this right now so help me please.
I have a web.config looks like this:
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
And in my web.Debug.config:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="ApplicationServices"
connectionString="value for the deployed Web.config file"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
I then run the "Debug", and want to access the configuration in the web.Debug.config and NOT the web.config. But it always returns the web.config, what i'm doing wrong? The code for retreiving looks like this:
ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString
Upvotes: 0
Views: 76
Reputation: 22511
The web.*.config files are for transforming your web.config and therefore are called "Web.Config Transformations".
The transformations are only run when you publish/deploy the web application, not by just debugging your application. That's the reason why the web.Debug.config in particular is rarely used (maybe for a test system if you don't use another configuration for that).
In order to use special debug settings, follow this approach:
Upvotes: 3