有没有一种方法可以将app/web.config拆分为2个文件? [英] Is there a way to split app/web.config into 2 files?

查看:131
本文介绍了有没有一种方法可以将app/web.config拆分为2个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用app/web.config为我的数据库存储连接字符串,这意味着在升级时,我们不会触摸配置文件来保留这些字符串.但是,我们现在要转到MVC5,这样做需要在app/web.config(我们有一个App和一个配置类似的网站)中更新所有库定义.

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).

那么是否可以将这些文件分为两个文件,以便我可以更新库定义,同时保持现有基础结构的完整性,以从.config文件中读取连接字符串?还是有另一种方法可以解决这个问题?

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>

connections.config文件将以<connectionStrings>...</connectionStrings>开头.

这篇关于有没有一种方法可以将app/web.config拆分为2个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆