覆盖machine.config中使用的web.config [英] Override machine.config with web.config

查看:191
本文介绍了覆盖machine.config中使用的web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我决定把我的连接字符串的machine.config,因为这似乎是迄今为止用于管理多个环境最优雅的方式。不过,我仍想能够在需要的时候在我的本地web.config中覆盖这些设置(或不开明的群众开始抱怨)。

I have recently decided to move my connection strings to machine.config as this seems to be by far the most elegant approach for managing multiple environments. However, I would still like to be able to override these settings in my local web.config if the need arises (or the non-enlightened masses begin to complain).

我怎么能覆盖从machine.config的在我的web.config的设置没有得到一个 ConfigurationErrorsException 因为值已设定?

How can I override settings from machine.config in my web.config without getting a ConfigurationErrorsException because the value has already been set?

推荐答案

如果你想使用本地web.config中,有你在machine.config中已经添加了名称相同添加另一个连接字符串,则首先需要将其删除。元素就像一本字典中的ConnectionStrings,您可以添加替换字符串前添加删除或清除标记。看看这个了解详细信息。

If you're trying to add another connection string using the local web.config that has the same name as one you've added in machine.config, you will need to remove it first. The connectionStrings element works like a dictionary, you can add a remove or clear tag before adding the replacement string. Take a look at this for details.

这篇关于覆盖machine.config中使用的web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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