Mid ASP.NET Core

Using Options pattern (IOptions<T>, IOptionsSnapshot<T>,?

IOptionsMonitor<T>)

  • IOptions<T>: Reads settings once at startup.
  • IOptionsSnapshot<T>: Gets updated settings per request (for scoped services).
  • IOptionsMonitor<T>: Supports change notifications and works in singleton

services.

public MyService(IOptions<MySettings> options) {

var settings = options.Value;

More from ASP.NET Core Tutorial

All questions for this course