Sheer Vision Logo

One Web.config

Written by Jason Noftall, VP Technology

Introduction

Working on a multi-developer ASP.NET project while sharing one web.config can be time consuming and troublesome. Usually, each developer may have path and other settings specific to their development machine, such as Database connection strings, paths, e-mail addresses, etc. For example, each developer on a project may be running a database locally that the application relies on during development. Therefore, the connection string would be different for each developer.

A Solution

One way to determine and load the appropriate web.config settings is by first reading the machine (computer) name. 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. See the sample web.config below.

A good place to read these settings may be in Global.asax’s Session_Start() method. See the code sample below.

Note

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.

History

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

Print this Page   E-mail this Page
Powered By: ssCMS 2.1.0.0