posted on Thursday, April 14, 2005 1:46 AM by Saravana

AppSettings can Reference an External Config File - Contd....

I have blogged about "AppSettings can Reference an External Config File" previously. Today i read about another use of having external config file,

Short story:

External config file setting will override the main config file settings. If the external config file is missing, ASP.NET runtime won’t raise any error, it will silently pick up the values from main config file. Therefore, override development or testing specific appsettings in external config file but dont deploy the external config file in production server. So that in production server, appsettings value will be picked from main config file, but in development or testing machine it will pick it from external config file.

 

Long story:

In team development scenario, you might come across a situation where you might require to store connection string or web service url in config file (appsettings element). However, during development and testing you might require changing these settings to match your development and testing server settings. Instead of changing this settings whenever you deploy it in production server, you can have user specific config file in your system where you can override these settings and specify this user config file in main web.config file.

During development, in each developer machine they can change the setting in user config file depending upon their requirement without touching the main config file. However, dont check in that config file, so that in the production server you won’t have this config file. If you dont have the config file in production server, it will pick up the appsettings value from main config file. However, in development machine it will pick it up from external config file. More details about this in,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch3.asp

Comments