Click here to Skip to main content
13,291,690 members (53,745 online)
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 5 Aug 2004

One web.config for all developers

, 5 Aug 2004
Rate this:
Please Sign up or sign in to vote.
Allows ASP.NET developers and the final production environment to share one web.config file


Working on a multi-developer ASP.NET project while sharing one web.config can be time consuming. Usually, each developer may have path and other settings specific to their development machine, such as database connection strings, paths, e-mail addresses, etc.


Switching from a ASP 3.0 server-based development environment to a code versioning ASP.NET local-based development environment posed the challenge of all development machines having different settings. It is too time-consuming and tedious to have multiple copies of web.config, which is why we came up with the notion of reading the machine name and loading the appropriate settings from there.

Using the code

One way to determine and load the appropriate web.config setting is by first reading the machine (computer) name (Note: Ensure System.Environment is not locked down in the ISP’s hosting policy). Once the machine name is obtained, it can then be used as a numeric offset that is used in all other web.config variables that would be developer-specific. A good place to read these settings may be in Global.asax’s Session_Start() method.

// Get this machine's name.
thisMachineName = System.Environment.MachineName.ToUpper();

// Get production machine name from web.config.
machineNameSetting = ConfigurationSettings.AppSettings["machine_name_remote"];

// Was the production machine found?
if (thisMachineName == machineNameSetting)
    // Load "remote/live/production" settings.
    index = "_remote";
    devMachineFound = true;
    // Load developer settings...
    // (see demo project)

Points of Interest

While this code works well, the ability to retrieve the machine name may be locked down by your host's security policy. Please check with them before assuming this code will run.


This methodology is used in all of our ASP.NET applications.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jason Noftall
Web Developer
Canada Canada
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralGreat for use with a CVS Pin
PaKettle10-Aug-04 5:00
memberPaKettle10-Aug-04 5:00 
GeneralRe: Great for use with a CVS Pin
Jason Noftall10-Aug-04 5:08
memberJason Noftall10-Aug-04 5:08 
GeneralRe: Great for use with a CVS Pin
Ashley van Gerven30-Aug-04 4:44
memberAshley van Gerven30-Aug-04 4:44 
GeneralStandard override possibility for web.config/appSettings Pin
Victor Vogelpoel10-Aug-04 2:53
memberVictor Vogelpoel10-Aug-04 2:53 
Generalgood, but could be explained a bit better Pin
Ashley van Gerven7-Aug-04 2:20
memberAshley van Gerven7-Aug-04 2:20 
GeneralRe: good, but could be explained a bit better Pin
Jason Noftall9-Aug-04 15:27
memberJason Noftall9-Aug-04 15:27 
GeneralRe: good, but could be explained a bit better Pin
Ashley van Gerven9-Aug-04 19:12
memberAshley van Gerven9-Aug-04 19:12 
GeneralI'm missing something. Pin
soup6-Aug-04 6:13
membersoup6-Aug-04 6:13 
GeneralRe: I'm missing something. Pin
Ashley van Gerven7-Aug-04 2:24
memberAshley van Gerven7-Aug-04 2:24 
GeneralRe: I'm missing something. Pin
Jason Noftall9-Aug-04 15:14
memberJason Noftall9-Aug-04 15:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 6 Aug 2004
Article Copyright 2004 by Jason Noftall
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid