Friday, January 29, 2010 8:57 PM
While exploring configuration files I stumbled upon a few cool things which we could do with these. (Web.Config and App.Config)
Including a configuration into another.
We can create a separate file for the AppSettings section of the Web.Config and refer it in the <AppSettings> tag.
e.g.
<appSettings file= "testAppSettings.config" >
</appSettings>
We can also include the connection strings from a separate files into the Configuration file.
<connectionStrings configSource = "WebConnectionString.config" >
</connectionStrings>
This will enable us to have multiple configurations for trials and rather than making specific to the web.config everytime and a lot of commented tags, we can just change the filenames and keep the Web.config clean.
Default values in configuration settings.
In spite of having separate configuration files we can still choose to have a standard set of values to default to in absence of any referred files.
e.g
<appSettings file = "testAppSettings.config" >
<add key = "UserName" value = "testUser"/>
<add key = "Password" value = "Abc1234$$" />
</appSettings>
<connectionStrings configSource = "WebConnectionString.config">
<!—Your connection string here -->
</connectionStrings>
In this case if the referred configuration files are not available then the values are defaulted to the ones specified in the Web.Config/App.Config