Separate configuration file for suppliers
In a small test project, I currently have vendor sections in my web.config file. I want to move this into a separate config file, like services.config. My current provider instantiation code is like:
//Get the feature configuration info
ProviderConfiguration pc = (ProviderConfiguration)ConfigurationManager.GetSection(DATA_PROVIDER_NAME);
This code works if the provider information is in the web.config, but the way I read that information from another file (like providers.condfig) is because the ConfigurationManager seems to only "read" the web.config file. I might have something very simple here :)
Would love to have more input on this.
Thank you in
+2
a source to share
1 answer
If you want to reference an external file for a set of settings in your web.config file, you can do this:
<?xml version="1.0"?>
<configuration>
<appSettings file="externalSettings.config"/>
<connectionStrings/>
<system.web>
<compilation debug="false" strict="false" explicit="true" />
</system.web>
Hope it helps.
So, in your case, you can do something like this:
<configSections>
<section name="ProviderName" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<ProviderName file="provider.config" />
0
a source to share