0Pricing
C# Academy · Lesson

Configuration Sources & Providers

Layer configuration from JSON files, environment variables, command-line args, and custom providers with priority.

Configuration in .NET

ASP.NET Core's configuration system reads settings from multiple sources — JSON files, environment variables, command-line args, and more — and merges them into one flat key-value store accessible anywhere in your app.

appsettings.json

appsettings.json is the default configuration file. It is loaded automatically by Host.CreateApplicationBuilder. Settings are merged with environment-specific overrides.

// appsettings.json
{
  "App": {
    "Name": "OrderService",
    "MaxRetries": 3
  },
  "ConnectionStrings": {
    "Default": "Server=localhost;Database=orders"
  }
}

// appsettings.Production.json overrides the above:
{
  "ConnectionStrings": {
    "Default": "Server=prod-db;Database=orders;..."
  }
}

All lessons in this course

  1. Configuration Sources & Providers
  2. Strongly Typed Options with IOptions
  3. Options Validation & Named Options
  4. Secrets Management
← Back to C# Academy