liveBook · Manning

Appsettings.Development.json

As explained in .NET in Action, Second Edition

appsettings.Environment.json is the conventional ASP.NET Core configuration file whose Environment placeholder is replaced by the current environment name.

appsettings.Development.json is the conventional environment-specific ASP.NET Core configuration file. The filename replaces Environment with the current environment name, such as Development. ASP.NET Core loads appsettings.json first, then loads the matching environment file; matching keys in the later file override earlier values. section 3.1 section 13.4.2

Use the file to provide non-secret settings that vary by environment:

  • Set the environment name through the ASPNETCORE_ENVIRONMENT value in launchSettings.json; the matching filename is then selected. section 3.1
  • Place development values in appsettings.Development.json while keeping shared defaults in appsettings.json. section 3.1 section 13.4
  • Expect later sources—including user secrets, environment variables, and command-line arguments—to override both JSON files when keys collide. section 13.4.2
  • Keep secrets separate from ordinary configuration; examples of secrets include cryptographic keys, connection strings, and API keys. section 13.4

Expose environment-specific values

Store {"EnvironmentName":"Development","RegionName":"My Desk"} in appsettings.Development.json. An ASP.NET Core controller can read these values through IConfiguration and return them from a GET /config endpoint. section 13.4

Listing 13.10 Environment-specific configuration values in appsettings
{
  "EnvironmentName": "Development",
  "RegionName": "My Desk"
}

Inspect a concrete appsettings.Development.json payload containing EnvironmentName and RegionName. section 13.4

How .NET in Action, Second Edition covers it

How deep it goes
Explains filename matching, loading precedence, and overrides, then demonstrates values through IConfiguration and a controller endpoint.
Examples
Uses Development and region values, a /config endpoint, and a TestOverwrite key to demonstrate successive overrides.
What it assumes
Assumes an ASP.NET Core web application and teaches environment-based JSON configuration through appsettings files and IConfiguration.
What you can do after
Operate/configure ASP.NET Core applications with environment-specific defaults and verify precedence through an HTTP configuration endpoint.
How it connects
Connects ASP.NET Core configuration with IConfiguration, environment variables, user secrets, and command-line arguments.

Also explained in

Compare how 3 books explain appsettings.Development.json →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.