-
1
May
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!
- Published by gchandra in: Asp.Net Web Web Coding
- If you like this blog please take a second from your precious time and subscribe to my rss feed!
One Response to “Handling multiple configuration settings (Development, Staging, Production) gracefully.”
Leave a Reply