appsettings.json is the conventional .NET application configuration file for default JSON settings. ASP.NET Core loads it before environment-specific configuration and exposes the combined values through IConfiguration. section 3.1 section 13.4.2
Use the configuration hierarchy to separate defaults from deployment-specific values:
- Place shared or default values in appsettings.json. section 3.1
- Override matching keys in appsettings.<environment>.json, such as appsettings.Development.json; the environment name comes from an environment variable. section 3.1
- Allow user secrets, environment variables, and command-line arguments to override earlier values in that order. section 13.4.2
- Read values through IConfiguration, which combines and flattens the available configuration sources. section 13.4.2
Environment-specific defaults
A base appsettings.json can define shared values, while appsettings.Development.json contains {"EnvironmentName":"Development","RegionName":"My Desk"}. A controller can receive IConfiguration through dependency injection and return those values from a GET endpoint. section 13.4
Listing 13.10 Environment-specific configuration values in appsettings
{
"EnvironmentName": "Development",
"RegionName": "My Desk"
}
Inspect a concrete environment-specific appsettings JSON object containing EnvironmentName and RegionName. section 13.4



