Configuration Specific Web.Config in Visual Studio 2010

by Admin 30. July 2010 10:03

A cool feature of Visual Studio 2010 is the ability to have configuration files that are build configuration specific. Handling build configuration specific config files was always a challenge in the past where one had to store multiple config files for a dev environment versus a staging environment versus a production environment.

For example, a dev environment specific conf file would store the connection string to your dev database and the production envirnment web.config would store the connection string to your production database. Now when you moved your code between environments, you would have to make sure that the correct config file is copied over and that your production environment code is not accidentally pointing to your dev database.

This problem is solved by visual studio 2010 that allows cbuild configuration specific config files. In VS 2010, whenever you create a new web application project now, you'll see that your web.config in your solution explorer actually appears as an expandable node. When you expand it, you will see multiple configuration files for each of your build configurations, that can hold different values for each configuration.

Now when you build your application in a specific build configuration, the correct web.config settings get applied. Similarly when you publish, the correct web.config settings get published.

Tags: , , ,

ASP.Net | VseWss 3.0 v1.3