Configuration & Environments Flashcards
6 cards from real ASP.NET Core practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Configuration & Environments flashcards as text
What is the default hierarchy of configuration providers in ASP.NET Core?
Answer: appsettings.json → appsettings.{Env}.json → Environment variables → Command-line (last wins)
Later providers override earlier ones: appsettings.json → environment-specific file → env vars → command-line args.
Which environment variable sets the current environment in ASP.NET Core?
Answer: ASPNETCORE_ENVIRONMENT
ASPNETCORE_ENVIRONMENT sets the hosting environment name, which determines which appsettings.{Env}.json file is loaded.
How do you bind a configuration section to a strongly-typed class?
Answer: Configuration.GetSection("Key").Bind(instance)
GetSection("Key").Bind(instance) or GetSection("Key").Get() maps configuration values to properties of a strongly-typed class.
What does IOptions provide compared to IOptionsSnapshot?
Answer: IOptions is singleton and does not reload; IOptionsSnapshot reloads per-request
IOptions is a singleton that doesn't reload; IOptionsSnapshot is scoped and reflects configuration changes per request.
Which interface provides configuration that reloads when the source file changes?
Answer: IOptionsMonitor
IOptionsMonitor is a singleton that fires a change notification and provides the latest configuration when the source changes.
How do you add a custom configuration source in ASP.NET Core?
Answer: Implement IConfigurationSource and IConfigurationProvider, then call builder.Configuration.Add()
You implement IConfigurationSource to describe the source and IConfigurationProvider to load data, then add it via builder.Configuration.Add().