.NET Tip: Managing Development and Production Configuration Files Cincinnati OH

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

3D Computer Systems
513-569-0500
2230 Auburn Ave
Cincinnati, OH
The Shepherd Chemical Co.
(513) 731-1110
4900 Beech Street
Norwood, OH
A-Hi Computers & Electronics
(513) 531-1111
4030 Montgomery Road
Cincinnati, OH
Netburg Consulting Services
513-247-9701
150 E 4th Street
Cincinnati, OH
Graphic Informatn Systems Inc
513-948-1300
7633 Production Dr
Cincinnati, OH
21st Century Designs Inc.
(513) 662-5862
P.O. Box 112091
Cincinnati, OH
Greater Cincinnati Computer
513-985-1300
7024 Plainfield Rd
Cincinnati, OH
Cincinnati PC Solutions
513-871-3600
4770 Redbank Expressway
Cincinnati, OH
Chemical Systems International Inc.
(513) 385-6688
3567 Blue Rock Road
Cincinnati, OH
MIKAL Salon and Spa Computers
513-528-5100
4382 Mt Carmel Tobasco Rd
Cincinnati, OH

 

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

3D Computer Systems

513-569-0500
2230 Auburn Ave
Cincinnati, OH

Related Local Event
Forge Fair 2010
Dates: 4/20/2010 - 4/22/2010
Location: Cincinnati Convention Center
Cincinnati, OH
View Details