【发布时间】:2018-02-13 23:13:14
【问题描述】:
在使用 XML 配置的“过去”中,可以包含来自另一个文件(如 this)的部分配置:
<appSettings file="relative file name">
<!-- Remaining configuration settings -->
</appSettings>
现在在 ASP.NET Core 中,我想在 appsettings.Development.json 以及例如 appsettings.Staging.json 中分享一些配置。像 <appSettings file=""> 这样的东西是否也可以使用 json 配置?
【问题讨论】:
-
您可以在启动代码中添加任意数量的 JSON 文件。
-
当然,但我试图防止 json 文件本身之间的重复
-
不清楚您所说的“防止重复”是什么意思。您不需要在其他文件中有重复的内容,只需根据需要添加新的位,框架会负责将它们合并到更大的配置中。如果存在,每个附加文件将覆盖前一个文件中的值,否则将添加到它。
-
问题对我来说很清楚。 web.config 文件,即允许您外部引用其他配置文件link 现在,我有一个主机 prj 和一个 mirgrate prj,我必须同时维护它们。
标签: c# asp.net-core .net-core configuration-files asp.net-core-2.0