[英]Is it possible to have multiple services or applications share one single config file
如果我有多个共享一个配置值的应用程序或服务(例如,它们都访问同一个数据库),有没有办法让它们共享一个配置文件而不必在每个配置中复制值?
You could use the machine.config file to define settings shared between all applications on this computer. 您可以使用machine.config文件来定义此计算机上所有应用程序之间共享的设置。 For ASP.NET applications you could have a web.config file at the root of the file which overrides those machine.config values and have yet another level inside the virtual directory. 对于ASP.NET应用程序,您可以在文件的根目录下有一个web.config文件,该文件会覆盖这些machine.config值,并且在虚拟目录中还有另一个级别。
You can use the configSource
attribute to point to a specific file. 您可以使用configSource
属性指向特定文件。
Use the same file location from multiple .config
files. 使用多个.config
文件中的相同文件位置。
You can do this with multiple config sections, so one file for connection strings, one for app settings etc... 您可以使用多个配置部分执行此操作,因此一个文件用于连接字符串,一个用于应用程序设置等...
You can load config file programmatically 您可以以编程方式加载配置文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.