I am used to building ASP.Net Web Sites and dealing only with a single web.config. I am now building my first Web Application and can nto understand how to build the web.config file(s). The application made a main web.config and under it are a web.debug.config
and web.release.config. Which of the 3 do I add info to and what is the point of the 3 different onces?
This is a feature in Visual Studio 2010 known as web.config transformation. It gives you the ability to create multiple web.config files for easy deployent to various environments. Example, web.release.config would normally be used when you are deploying
the final version whereas web.debug.config is used when you are compiling and publishing to testing for debug.
It still results in a single web.config file, which is the naming convention you will use. The others are simply to help more advanced development and testing scenarios.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
I read over that site but it still is not clear where I put data. Like for my connection string do I add one to each web.config or just 1 for each of the debug and release? It is also very confusing on the xdt commands. I did searching and can't find anything
with better examples of how to deal with the multiple web.configs or a clearer explination of what exactly your supposed to do.
Maybe I miss understood what they are for but when I place this code in the primary web.config it is not being updated by my web.debug.config when I do an F5 debug on the appliction.
The transformation only happens when you publish, and the changes are only made in the copy of the Web.config file that is on the destination web server.
Marked as answer by eagle_f90 on Nov 24, 2012 09:20 PM
So if I code the dev DB connection data into the web.config would it still be overridden by the web.release.config when published eventhough the attributes are not empty?
Eagle_f90
Member
465 Points
532 Posts
how does the web.config work in Web Applications?
Nov 22, 2012 09:44 PM|LINK
I am used to building ASP.Net Web Sites and dealing only with a single web.config. I am now building my first Web Application and can nto understand how to build the web.config file(s). The application made a main web.config and under it are a web.debug.config and web.release.config. Which of the 3 do I add info to and what is the point of the 3 different onces?
markfitzme
Star
14453 Points
2232 Posts
Re: how does the web.config work in Web Applications?
Nov 23, 2012 12:34 AM|LINK
This is a feature in Visual Studio 2010 known as web.config transformation. It gives you the ability to create multiple web.config files for easy deployent to various environments. Example, web.release.config would normally be used when you are deploying the final version whereas web.debug.config is used when you are compiling and publishing to testing for debug.
More information on this feature of VS 2010 can be found at: http://blogs.msdn.com/b/webdev/archive/2009/05/04/web-deployment-web-config-transformation.aspx
It still results in a single web.config file, which is the naming convention you will use. The others are simply to help more advanced development and testing scenarios.
Eagle_f90
Member
465 Points
532 Posts
Re: how does the web.config work in Web Applications?
Nov 23, 2012 12:44 AM|LINK
I read over that site but it still is not clear where I put data. Like for my connection string do I add one to each web.config or just 1 for each of the debug and release? It is also very confusing on the xdt commands. I did searching and can't find anything with better examples of how to deal with the multiple web.configs or a clearer explination of what exactly your supposed to do.
tdykstra
Contributor
4463 Points
624 Posts
Microsoft
Moderator
Re: how does the web.config work in Web Applications?
Nov 23, 2012 02:13 AM|LINK
See this tutorial series about deployment:
http://www.asp.net/mvc/tutorials/deployment/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-introduction-1-of-12
The third in the series explains Web.config transformation:
http://www.asp.net/mvc/tutorials/deployment/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-web-config-file-transformations-3-of-12
Eagle_f90
Member
465 Points
532 Posts
Re: how does the web.config work in Web Applications?
Nov 24, 2012 09:08 PM|LINK
Maybe I miss understood what they are for but when I place this code in the primary web.config it is not being updated by my web.debug.config when I do an F5 debug on the appliction.
<connectionStrings> <add name="FFCollection" providerName="System.Data.SqlClient" connectionString="" /> </connectionStrings>web.debug.config
<connectionStrings> <add name="FFCollection" connectionString="Data Source=192.168.0.2; Initial Catalog=FFCollection; User ID=; Password=;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>tdykstra
Contributor
4463 Points
624 Posts
Microsoft
Moderator
Re: how does the web.config work in Web Applications?
Nov 24, 2012 09:11 PM|LINK
The transformation only happens when you publish, and the changes are only made in the copy of the Web.config file that is on the destination web server.
Eagle_f90
Member
465 Points
532 Posts
Re: how does the web.config work in Web Applications?
Nov 24, 2012 09:19 PM|LINK
Is there a way to to make them happen when I hit the debug button?
tdykstra
Contributor
4463 Points
624 Posts
Microsoft
Moderator
Re: how does the web.config work in Web Applications?
Nov 24, 2012 10:02 PM|LINK
No. When you hit debug you'll get whatever is currently in Web.config.
Eagle_f90
Member
465 Points
532 Posts
Re: how does the web.config work in Web Applications?
Nov 24, 2012 10:11 PM|LINK
So if I code the dev DB connection data into the web.config would it still be overridden by the web.release.config when published eventhough the attributes are not empty?
tdykstra
Contributor
4463 Points
624 Posts
Microsoft
Moderator
Re: how does the web.config work in Web Applications?
Nov 24, 2012 11:44 PM|LINK
Yes, if the transformation file is coded correctly it will replace whatever is in the Web.config file in the local project.