I am starting asp.net core 2.1 coming from .NET and wondering how do I make multiple AppSetting.json files?
Before we had the webconfig that you could have webconfig.debug, webconfig.prod and etc.
What is the core equivalent to that?
Of course, we can add and use multiple appsettings. json files in ASP.NET Core project. To configure and read data from your custom json files, you can refer to the following code snippet.
NET Core and as far as I see from my search on the web, appsettings.Development. json is used for development config while developing the app and appsettings. Production. json is used on the published app in production server.
json programmatically. You have to overwrite the appsettings. json file to be able to update values programmatically.
By default ASP.NET Core will attempt to load an additional appsettings.<EnvironmentName>.json
file. Using the default environment names available, this allows you to create the following files:
appsettings.json
- loaded regardless of the environment nameappsettings.Development.json
- loaded only when the environment name is Development
appsettings.Staging.json
- loaded only when the environment name is Staging
appsettings.Production.json
- loaded only when the environment name is Production
The name of the environment is usually controlled via the ASPNETCORE_ENVIRONMENT
environment variable or via launchSettings.json
when developing (checkout the docs).
Take a look at the documentation for configuration for more info regarding this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With