While working with Visual Studio 2010, a new feature caught my eye that isn’t communicated (strongly) in the “What’s new” lists you can find online. As part of the Visual Studio 2010 supports multiple web.config files! Now we can create a separate web.config file for each configuration we have for our application. If you add a configuration through the configuration manager, you have the possibility to add a web.config file for the new configuration too.
A web application gets two configurations by default: a Debug and a Release configuration. When opening the plus sign in front of the web.config file, two extra files appear: web.debug.config and web.release.config. Depending on the active configuration, Visual Stusio selects the correct version.
The web.config file contains the default configuration. Configuration specific config files may add or remove settings or change current ones. This is done using simple transformation tags.
For more information on transformations have a look at:
- Web Deployment: Web.Config Transformation (Visual Web Developer Team Blog)
- Web.config Transformation Syntax for Web Application Project Deployment (MSDN library)