What are the Web.Debug.config and Web.Release.Config files for?


What are the Web.Debug.config and Web.Release.Config files for?



I just upgraded to Visual Studio 2010 and MVC 2.0 and I noticed the Web.config has two additional files attached to it? Are these files used to specify debug and release specific settings, so you don't clutter up the main Web.config?

Does it even make sense to place a connection string in the root Web.config file if I have a local and remote one in the debug and release Web.configs respectively?

Thanks!




Can someone explain this block of ASP.NET MVC code to me, please?

1:



How make data entry using autogenerated texboxes in ASP.NET MVC?
It's the new Web.config transformation feature of Visual Studio 2010.


Inline HTML Syntax for Helpers in ASP.NET MVC
More information here..
How to show route default value?
Edit: .
“404 Not Found” error in mvc
Are these files used to specify debug and release specific settings, so you don't clutter up the main web.config?.
ASP.NET MVC Authentication Cookie Not Being Retrieved (UPDATED)
It isn't limited to three files, you could (in theory) have as many files as you have environments.


How do I add my SQL Server 2005 database to my VS MVC 2 project?
The "top level" Web.config provides a template of your web config.


how to make a session persistent with .net
The files under it provide replacement values specific to that environment (like if you have different connection strings for local/stage/test/whatever)..
Does it even make sense to place a connection string in the root web.config file if I have have a local and remote one in the debug and release web.configs respectively..
It would only make sense if it wasn't going to change between environments.

Sounds like in your case it does so, in your case no, it would not make sense to leave it in the Web.config..


2:


These are Web.config transformations files.

From ASP.NET Web Deployment using Visual Studio: Web.config File Transformations:.
There are two ways to automate the process of changing Web.config file settings: Web.config transformations and Web Deploy parameters.

A Web.config transformation file contains XML markup that specifies how to change the Web.config file when it is deployed.
You can specify different changes for specific build configurations and for specific publish profiles.

The default build configurations are Debug and Release, and you can create custom build configurations.

A publish profile typically corresponds to a destination environment..


3:


In case anyone is interested, here is something I wrote up to have a dynamic connection string per environment.

I wanted to deploy the code to any environment (Dev, Test, Pre-Prod, Prod...) without having to worry about changing connection strings.

I couldn't really find a good way to do this with Asp.Net MVC 4, so I came up with my own way to rely on a properties file per environment.

. There may be a better solution, I come from a Wicket/Java background and recently started developing with MVC 4 so, it's possible a better solution exists.

But here is a link to my question and answer for a dynamic connection string:. Asp.net MVC 4 dynamic connection string.


4:


That was something long needed in VS.

Unfortunately there seems to be a problem with the implementation.

For example consider this scenario (VS.2010 Ultimate, all SP):. Web.Config.
  • No connectionStrings section
  • Full Membership User/Role/etc.

    Provider configuration using connectionStringName="test"
Web.Release.Config.
  • No membership configuration (already specified in main web.config)
  • connectionStrings section including the CS named "test"
Web.Debug.Config.
  • No membership configuration (already specified in main web.config)
  • connectionStrings section including the CS named "test"
When executing the application gives the following error:.
The connection name 'test' was not found in the applications configuration or the connection string is empty..
In other words, because the connection string elements are in the Release/Debug designer files and used by configuration elements in the main (Web.config) file, it is unable to resolve it..



62 out of 100 based on 47 user ratings 172 reviews

@