简体   繁体   中英

Is there a way to split app/web.config into 2 files?

I currently use app/web.config to store Connection Strings for my database, which means on upgrade we do not touch the config files to preserve those strings. However we now want to move to MVC5 and doing so requires all the library definitions to be updated within the app/web.config (we have both an App and a website with similar configuration).

So is it possible to split these files into two files so that I can update the library definitions whilst keeping intact my existing infrastructure to read out the connection strings from the .config files? Or is there another method to deal with this?

Yes; you simply create a second file rather than including things inline, for example:

<configuration>
    <connectionStrings configSource="connections.config"/>
</configuration>

The connections.config file would start with <connectionStrings>...</connectionStrings> .

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