What is configuration in ASP.NET Core?
Quick Interview Answer
Detailed Explanation
Configuration in ASP.NET Core is the system used to read application settings from multiple sources and expose them through a unified key-value interface.
Common configuration sources include appsettings.json, environment-specific JSON files, environment variables, command-line arguments, user secrets during development, and custom providers such as Azure Key Vault.
ASP.NET Core builds configuration during application startup. Values can be read directly through IConfiguration or bound to strongly typed options classes. Later configuration providers normally override earlier providers when the same key exists.
Configuration should contain settings such as connection strings, API endpoints, feature flags, and operational values. Sensitive production secrets should not be committed to source control.
Code Example
var builder = WebApplication.CreateBuilder(args);
var connectionString =
builder.Configuration.GetConnectionString("DefaultConnection");
var apiUrl = builder.Configuration["ExternalApi:BaseUrl"];