Environments
In the previous section, we introduced how to read the configuration settings from various resources, including the appsettings.json
file, user secrets, environment variables, and command-line arguments. In this section, we will discuss environments in more detail.
Run the following command to create a new ASP.NET Core web API project:
dotnet new webapi -n EnvironmentDemo -controllers
You can download the example project named EnvironmentDemo
from the /samples/chapter3/EnvironmentsDemo
folder in the chapter's GitHub repository.
We have mentioned the default ASP.NET Core web API template contains an appsettings.json
file and an appsettings.Development.json
file. When we run the application using dotnet run
, the application runs in the Development
environment. So the configuration settings in the appsettings.Development.json
file override the configuration settings in the appsettings.json
file.
Add the following section to the appsettings.Development.json...