开发者

Separate config file for Providers

In a small test project, I currently have the provider sections in the web.config. I want to move that to a separate config file, like providers.config. My current provider开发者_开发技巧 instantiation code is like:

   //Get the feature's configuration info
                    ProviderConfiguration pc = (ProviderConfiguration)ConfigurationManager.GetSection(DATA_PROVIDER_NAME);

This code works if the provider info is in web.config, but how to I read this info from another file (like providers.condfig) because it seems that the ConfigurationManager "reads" only web.config file. I may be missing something very simple here :)

Would love to get more inputs on this.

Thanks V


If you want to reference an external file for a collection of settings in the web.config 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 this 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜