โ† All ASP.NET Core Flashcard Decks

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
  1. What does services.Configure() do in the DI container?

    Answer: Binds a configuration section to an options class and registers it

    services.Configure() reads a configuration section and registers it so it can be injected via IOptions, IOptionsSnapshot, or IOptionsMonitor.

  2. How do you perform options validation in ASP.NET Core?

    Answer: Use services.AddOptions().ValidateDataAnnotations() or implement IValidateOptions

    ValidateDataAnnotations() checks data annotation attributes at runtime, while IValidateOptions allows custom validation logic.

  3. What is the purpose of the ConfigureAppConfiguration method in the host builder?

    Answer: Adds or customizes configuration sources for the application

    ConfigureAppConfiguration allows adding or modifying configuration providers such as JSON files, environment variables, or custom sources.

  4. Which configuration provider is used to read from Azure Key Vault?

    Answer: Azure.Extensions.AspNetCore.Configuration.Secrets

    The Azure.Extensions.AspNetCore.Configuration.Secrets NuGet package provides the AzureKeyVaultConfigurationProvider for reading secrets from Azure Key Vault.

  5. What is PostConfigure used for in the Options pattern?

    Answer: Applying configuration changes after all Configure calls have run

    PostConfigure() registers a callback that runs after all Configure callbacks, allowing final overrides or modifications to options.

  6. What happens when you call builder.Configuration.AddJsonFile("custom.json", optional: false, reloadOnChange: true)?

    Answer: Throws if the file doesn't exist and watches for file changes to reload config

    optional: false throws an exception if the file is missing, and reloadOnChange: true watches the file for changes and reloads configuration automatically.