简体   繁体   中英

Multiple external files in web.config?

I need to do something like this:

<appSettings>
  <add key="Three" value="NumberThree"/>    
</appSettings>
<appSettings configSource="One.config"/>
<appSettings configSource="Two.config"/>

This gives me an error: Sections must only appear once per config file.

That kinda sucks :( Just wondering: Is there any way/setting I can enable to do something like this? (IIS7, .net 3.5SP1)

I have very little control of the web.config and can't modify the existing appSettings element, only add new items.

Configurations have a set inheritance hierarchy.

Checkout ASP.NET Configuration File Hierarchy and Inheritance .

EDIT: Another one: How to: Configure Specific Directories Using Location Settings .

Not sure if this will help for you particular scenario. Have a look at the file attribute on <appSettings>

<appSettings file="Two.config">
  ...
</appSettings>

In Two.config you can then do the same to point to One.config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM