.NET Tip: Managing Development and Production Configuration Files Austin TX

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

Lone Star Internet
512-708-8006
211 E 7th Ste 1110
Austin, TX
Adhesive Software
512-478-7349
800 Brazos St
Austin, TX
Austin Programming Solutions
512-990-2151
900 Congress Avenue
Austin, TX
Activant Solutions Inc
512-328-2300
804 Las Cimas Pkwy
Austin, TX
MicroMain Corporation
512-328-3235
5100 Bee Caves Road
Austin, TX
MicroMain Corporation
523-328-3235
5100 Bee Caves Road
Austin, TX
Terminal B Information Technology Services
512-381-4800
108 Wild Basin Road, Suite 255, Austin, TX 78746
Austin, TX
Mojica PC Solutions
512-300-9956
614 S 1st Street
Austin, TX
Parts-People.Com Inc
512-339-1990
3106 Industrial Terrace
Austin, TX
IQgistics
512.535.4165
5900 Southwest Parkway
Austin, TX

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

Lone Star Internet

512-708-8006
211 E 7th Ste 1110
Austin, TX
http://www.lone-star.net

Related Local Events
Renewable Energy World Conference & Expo North America
Dates: 2/23/2010 - 2/25/2010
Location: Austin Convention Center, Austin
Austin, TX
View Details

Lone Star Ruby Conference 2009
Dates: 8/27/2009 - 8/29/2009
Location: Norris Conference Center
Austin, TX
View Details