1
Digg me

In Asp.net 2.0 multiple connectionStrings & appSettings can be handled very easily using the attribute “configSource”

create a new xml file devAppSettings.config under a new folder myConfigsettings

<?xml version=”1.0″?>
<appSettings>

  <add key=”uploadfolder” value=”C:\test\UploadDocs”/>

  <add key=”domainname” value=”devdomain”/>

</appSettings>


create a new xml file devconnectionStrings.config under a folder myConfigsettings

<?xml version=”1.0″?>
<connectionStrings>

  <add name=”nwind” connectionString=”Data Source=(localhost);Initial Catalog=nwind;User Id=sa;Password=sa;”
    providerName=”System.Data.SqlClient” />

</connectionStrings>


now modify web.config

<connectionStrings configSource=”myConfigsettings\devconnectionStrings.config”/>

<appSettings configSource=”myConfigsettings\devAppSettings.config” />
Similarly you can create as many config files for testing, production and change the name in Web.config

tstAppSettings.config

prdAppSettings.config


Tip: Unlike web.config,  these config files wont kill the session of current users if you accidentally enter a space and save the file.

If you enjoyed this post, make sure you subscribe to my RSS feed!


One Comment to “Handling multiple configuration settings (Development, Staging, Production) gracefully.”

  1. Handling multiple configuration settings (Development, Staging, Production) gracefully. « Script(s) | May 1st, 2008 at 8:58 pm

    [...] (continue reading…) Tagged with: web.config « How to Preserve Fileupload value in Asp.net ? [...]

Leave a Comment