.NET Tip: Managing Development and Production Configuration Files Sun City AZ

If you use one server to develop your applications and another to deploy them, you probably have to change your database connection settings each time you deploy your configuration files. Learn a quick fix for this problem.

Local Companies

CM/IT Solutions
(623) 486-4124
7566 W. Karen
Peoria, AZ
Warner Group LLC
(623) 328-8825
17505 N. 79th Ave.
Glendale, AZ
Gould Intelligent, LLC
(623) 328-8027
16845 N 29th Ave
Phoenix, AZ
Tec-Way
(602) 524-7203
Bret Phaneuf
Phoenix, AZ
BBB Systems, LLC
(602) 424-0914
2340 W. Mission
Phoenix, AZ
Blake Information Solutions
(623) 505-4888
13540 W. Camino Del
Sun City West, AZ
Adams I.T. Solutions
(602) 370-0605
Stacy Adams
El Mirage, AZ
Amerytech Networks
(732) 986-0125
6201 W. Olive Ave. #1130
Glendale, AZ
Gould Intelligent, LLC
(623) 328-8027
16845 N 29th Ave, #547
Phoenix, AZ
Lone Wolf Software Inc.
(623) 824-1140
6097 N 57th Drive
Glendale, AZ

provided by: 
Originally published at Internet.com


Most developers have one server they use to develop their applications and another server where they deploy the applications. The problem with this configuration is that you typically have to change your database connection settings, file locations, and so forth, each time you deploy your files. Inevitably, you'll add or remove settings from your configuration files and those settings won't be set up properly in the production environment.

A quick way to fix this problem is to use a prefix on your configuration settings and a function to determine which settings to use at runtime. Here's an example of a configuration file's appSettings section that is set up this way:

You then would create a function to wrap the ConfigurationManager class to determine which settings to retrieve, based on the Location setting: private string GetSetting(string setting) { string location = ConfigurationManager.AppSettings["Location"]; return ConfigurationManager.AppSettings[location + "." + setting]; }

Using this function is pretty easy: Response.Write(GetSetting("ConnectionString"));

When you deploy your code for this example, you can copy the entire configuration file to the server and simply change the Location from 'dev' to 'prod'. It's a fairly simple way to manage multiple configurations without a lot of work. You'd obviously want to beef up the GetSetting function to make sure that the setting wasn't empty, and so on, but the concept is something you might be able to use in your own applications.

About the Author

Eric Smith is the owner of Northstar Computer Systems, a Web-hosting company based in Indianapolis, Indiana. He is also a MCT and MCSD who has been developing with .NET since 2001. In addition, he has written or contributed to 12 books covering .NET, ASP, and Visual Basic. Send him your questions and feedback via e-mail at questions@techniquescentral.com.

Author: Eric Smith

Read article at Internet.com site

Featured Local Company

Blake Information Solutions

(623) 505-4888
13540 W. Camino Del
Sun City West, AZ

Related Local Events
Toastmasters
Dates: 3/25/2010 - 3/25/2010
Location: Peoria Chamber of Commerce
Peoria, AZ
View Details

Toastmasters
Dates: 5/6/2010 - 5/6/2010
Location: Peoria Chamber of Commerce
Peoria, AZ
View Details

Toastmasters
Dates: 6/17/2010 - 6/17/2010
Location: Peoria Chamber of Commerce
Peoria, AZ
View Details

Toastmasters
Dates: 7/29/2010 - 7/29/2010
Location: Peoria Chamber of Commerce
Peoria, AZ
View Details

Toastmasters
Dates: 9/9/2010 - 9/9/2010
Location: Peoria Chamber of Commerce
Peoria, AZ
View Details