Appsettings.json不同版本? [英] Appsettings.json Different Versions?

查看:299
本文介绍了Appsettings.json不同版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在启动来自.NET的asp.net core 2.1,想知道如何制作多个AppSetting.json文件?

I am starting asp.net core 2.1 coming from .NET and wondering how do I make multiple AppSetting.json files?

在拥有webconfig之前,您可以拥有webconfig.debug,webconfig.prod等.

Before we had the webconfig that you could have webconfig.debug, webconfig.prod and etc.

与之等效的核心是什么?

What is the core equivalent to that?

推荐答案

默认情况下,ASP.NET Core将尝试加载其他appsettings.<EnvironmentName>.json文件.使用可用的默认环境名称,这使您可以创建以下文件:

By default ASP.NET Core will attempt to load an additional appsettings.<EnvironmentName>.json file. Using the default environment names available, this allows you to create the following files:

  • appsettings.json-加载而与环境名称无关
  • appsettings.Development.json-仅在环境名称为Development
  • 时加载
  • appsettings.Staging.json-仅在环境名称为Staging
  • 时加载
  • appsettings.Production.json-仅在环境名称为Production
  • 时加载
  • appsettings.json - loaded regardless of the environment name
  • appsettings.Development.json - loaded only when the environment name is Development
  • appsettings.Staging.json - loaded only when the environment name is Staging
  • appsettings.Production.json - loaded only when the environment name is Production

开发环境时,通常通过ASPNETCORE_ENVIRONMENT环境变量或launchSettings.json控制环境的名称(

The name of the environment is usually controlled via the ASPNETCORE_ENVIRONMENT environment variable or via launchSettings.json when developing (checkout the docs).

看看

Take a look at the documentation for configuration for more info regarding this topic.

这篇关于Appsettings.json不同版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆