An overview of the Options pattern
In ASP.NET 5, we can use predefined mechanisms to enhance the usage of application settings. These allow us to divide our configuration into multiple smaller objects, configure them during multiple stages of the startup flow, validate them, and even watch for runtime changes with minimal effort.
The Options pattern's goal is to use settings at runtime, allowing changes to the application to happen without changes being made to the code. The settings could be as simple as a string
, a bool
, a database connection string, or a complex object that holds an entire subsystem's configuration.
This section explores different tools offered by ASP.NET Core to manage, inject, and load configurations and options into our programs. We will tackle different scenarios, from common ones to more advanced ones.
Getting started
The Options pattern in ASP.NET Core 5 allows us to load settings from multiple sources seamlessly. We can customize these...