- Home
- .NET coding challenges
- Configuring an appsettings.json environment
Configuring an appsettings.json environment
In ASP.NET Core, configuring an appsettings.json
environment variable can be done by creating appsettings.json
files with the environment name included.
For example, if we wanted to create an appsettings.json
file for the Production environment, we would create a separate file called appsettings.Production.json
and add the variables we wish to override.
Any variables not included in appsettings.Production.json
would default back to the main appsettings.json
file.
Watch our video where we go into more detail about it:
This is our appsettings.json
file:
{
"Authentication": {
"ClientId": "MyClient",
"ClientSecret": "MySecret",
"AllowedHosts": [
"localhost",
"localhost:8080"
],
"Attempts": 3
}
}
And this is our appsettings.Production.json
file:
{
"Authentication": {
"Attempts": 4
},
"LiveHost": "mydomain.com"
}
If an ASP.NET Core application was run in production, what would the values be for Authentication:ClientId
, Authentication:Attempts
and LiveHost
?
Related challenges

How to read an appsettings.json value in ASP.NET Core
See if you can read an appsettings.json configuration value from IConfiguration in an ASP.NET Core with our .NET coding challenge.