Modern applications need flexible, secure, and environment-aware configuration systems. ASP.NET Core provides one of the most powerful and extensible configuration frameworks in any web platform today. The modern configuration system is designed to work across environments, support multiple formats, enable strong typing, and integrate seamlessly with cloud platforms and secret management services.
Unlike the older .NET Framework approach that mainly relied on a single web.config file, ASP.NET Core's configuration system is built on a provider-based model. This allows configuration values to come from many different sources such as JSON files, environment variables, command-line arguments, secret stores, and cloud configuration services.

Why a Modern Configuration System?
Earlier systems had limitations:
Single configuration file
Hard to override values
No environment separation
No encryption support
Poor cloud compatibility
ASP.NET Core solves these through:
Multiple configuration providers
Hierarchical key-value structure
Environment-based configuration
Dependency injection support
Strongly typed settings
Secure secret management
Configuration Providers (Sources)
ASP.NET Core reads configuration from many providers in a specific order of priority:
appsettings.json
appsettings.{Environment}.json
User Secrets (Development only)
Environment Variables
Command-line Arguments
Later providers override earlier ones.
appsettings.json Example
{"Application": {
"Name": "DemoApp",
"Version": "2.1"},"Database": {
"ConnectionString": "Server=.;Database=DemoDB;Trusted_Connection=True;",
"Timeout": 30},"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning"
}}}Reading Configuration Values
Basic Example
var builder = WebApplication.CreateBuilder(args);
string appName = builder.Configuration["Application:Name"];
string connectionString = builder.Configuration["Database:ConnectionString"];
The colon (:) represents hierarchy inside JSON.
Environment-Specific Configuration
Create files:
appsettings.Development.json
appsettings.Staging.json
appsettings.Production.json
Example
{"Database": {
"ConnectionString": "Server=DEV;Database=TestDB"}}ASP.NET Core automatically loads the correct configuration based on:
ASPNETCORE_ENVIRONMENT=Development
Strongly Typed Configuration (Options Pattern)
Instead of accessing configuration with strings, map settings to C# classes.
Step 1: Create a settings class
public class DatabaseSettings
{
public string ConnectionString { get; set; }
public int Timeout { get; set; }
}
Step 2: Bind configuration
builder.Services.Configure<DatabaseSettings>(
builder.Configuration.GetSection("Database"));
Step 3: Inject into services/controllers
public class DataService
{
private readonly DatabaseSettings _settings;
public DataService(IOptions<DatabaseSettings> options)
{
_settings = options.Value;
}
}
Multiple Configuration Files
Load additional configuration files:

Join the conversation! Your thoughts help the community grow.