开发者

Override machine.config with 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 overrid开发者_运维知识库e these settings in my local web.config if the need arises (or the non-enlightened masses begin to complain).

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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜