.NET Tip: Managing Development and Production Configuration Files Wichita KS

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

Professional Software Inc
(316) 269-4264
800 E 1st St Ste 150
Wichita, KS
Allen Gibbs & Houlik L C Agh
(316) 267-7231
301 N Main St Ste 1700 Epic Center
Wichita, KS
Midwest CAM Solutions (GibbsCAM)
877-444-0982
NOW SERVING: KANSAS
Wichita, KS
Access Group LLC
(316) 264-0270
348 Ida St.
Wichita, KS
Jaray Software
(316) 267-5758
2030 S Mead St
Wichita, KS
Backup Solutions
(316) 944-4448
2707 W Douglas Ave Ste B
Wichita, KS
Vertical Solutions Inc
(316) 941-9429
2142 W Maple St
Wichita, KS
C E M Systems Inc
(316) 264-6116
1609 E 2nd St N
Wichita, KS
Arkane Systems
(316) 303-9579
1707 N Burns St
Wichita, KS
The Carnahan Group
316-634-6767
1551 Waterfront Parkway ste 110
Wichita, KS

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

Professional Software Inc

(316) 269-4264
800 E 1st St Ste 150
Wichita, KS

Related Local Event
Influencing without Authority
Dates: 12/3/2009 - 12/3/2009
Location: CMD Training Center WSU campus
Wichita, KS
View Details