appsettings.json is the conventional JSON configuration file for an ASP.NET Core application. It stores settings such as logging levels, allowed hosts, and database connection strings, which the configuration service turns into hierarchical properties. section 7.2.2 section 15.2
Listing 7.15 Adding a configuration setting in the appsettings.json file in the SportsStore folder
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"SportsStoreConnection": "Server=(localdb)\\MSSQLLocalDB;Database=
SportsStore;MultipleActiveResultSets=true"
}
}
Use the complete configuration listing to see the expected JSON structure, including nested logging settings and a ConnectionStrings entry. section 7.2.2
Configure appsettings.json with these practical constraints:
- Place connection strings under ConnectionStrings and give each one a distinct name, such as SportsStoreConnection, PeopleConnection, or IdentityConnection. section 7.2.2 section 38.2.1
- Keep each connection-string value on one unbroken line; the wrapped listings reflect page width rather than valid formatting. section 11.1.3
- Treat JSON syntax strictly: quote property names and values exactly, and use the connection-string format required by the database server. section 7.2.2
- Read settings through the configuration service, which merges appsettings.json with sources such as environment variables and command-line arguments. section 15.2
Environment-specific overrides
During startup, ASP.NET Core supplements appsettings.json with appsettings.Development.json when the environment is Development. Matching settings from the environment file replace the base values; for example, development logging can change Default from Information to Debug. section 15.2.1
The same pattern configures Entity Framework Core and ASP.NET Core Identity: define named database connections in JSON, then consume those names from application setup. section 32.2.2 section 38.2.1



