Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appsettings.json Different Versions?

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

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

What is the core equivalent to that?

like image 650
chobo2 Avatar asked May 17 '18 17:05

chobo2


People also ask

Can we have multiple Appsettings json?

Of course, we can add and use multiple appsettings. json files in ASP.NET Core project. To configure and read data from your custom json files, you can refer to the following code snippet.

What is difference between Appsettings json and Appsettings development json?

NET Core and as far as I see from my search on the web, appsettings.Development. json is used for development config while developing the app and appsettings. Production. json is used on the published app in production server.

Can we update Appsettings json?

json programmatically. You have to overwrite the appsettings. json file to be able to update values programmatically.


1 Answers

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

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.

like image 146
Henk Mollema Avatar answered Oct 20 '22 03:10

Henk Mollema