IConfiguration
The .NET interface for reading configuration, a merged set of key-value strings from settings files, environment variables and other providers.
In more detail
config["Catalog:DefaultPageSize"] returns a string or null, with no checking. Read it while wiring up the app, and depend on typed options everywhere else.
Related terms
- configuration provider — A source of configuration values, such as appsettings.json, an environment file, environment variables or user secrets.
- options pattern — Binding a configuration section to a plain class with typed properties, validating it, and injecting it into services instead of reading raw strings.
- configuration key — The name of a configuration value, written as a path with colons between levels, such as Catalog:DefaultPageSize.
- appsettings.json — The JSON settings file an ASP.NET Core app reads at startup, where each object is a configuration section.
Taught in
- The Options Pattern: Strongly Typed Configuration — Modern .NET Core, C# & Enterprise Microservices
- Environment Layering and User Secrets — Modern .NET Core, C# & Enterprise Microservices