Override machine.config with web.config

这一生的挚爱 提交于 2019-12-12 18:44:25

问题


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

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


回答1:


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.



来源:https://stackoverflow.com/questions/1982090/override-machine-config-with-web-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!