I have a web application in VS2010 with a web.config like this:
...
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=MyProdDb;Initial Catalog=MyCat;User Id=MyUser;Password=MyPass;"
providerName="System.Data.SqlClient" />
</connectionStrings>
...
and a Web.Debug.config like this:
...
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=MyDevDb;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
...
The project is set to create a Debug build, and when I run it in the debugger, I get MyProdDb
rather than MyDevDb
What am I missing?
UPDATED INFORMATION
Arbitrary XML-based .config files can now be processed, and the processing can happen at build time rather than at deployment time
http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx
Brilliantly, the transforms can also be previewed directly in Visual Studio.
As people have said the web.config versions only get applied at publish (MSDeploy) time. The normal way you would do things is to have your 'Debug' config in the actual web.config file and make changes to that for each of the deployment scenarios you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With