Kap*_*apé 8 c# configuration-files .net-core asp.net-core asp.net-core-2.0
在使用XML配置的"过去"中,可以包含来自另一个文件的部分配置,如下所示:
<appSettings file="relative file name">
<!-- Remaining configuration settings -->
</appSettings>
Run Code Online (Sandbox Code Playgroud)
现在在ASP.NET Core中我想分享一些配置appsettings.Development.json以及例如appsettings.Staging.json.类似于<appSettings file="">使用json配置也可以使用吗?
ans*_*erk 12
您可以在Startup类中添加mutliple配置文件:
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings-Development.json", optional: false)
.AddJsonFile("appsettings-Staging.json", optional: false)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅此处:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration ...
| 归档时间: |
|
| 查看次数: |
5165 次 |
| 最近记录: |