Skip to content

TOptions instance is validated when IOptions<TOptions>.Value is accessed #33837

@deep-outcome

Description

@deep-outcome

Description

From https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-8.0#validateonstart

Options validation runs the first time an IOptions<TOptions>, IOptionsSnapshot<TOptions>, or IOptionsMonitor<TOptions> implementation is created.

Options validation runs when IOptions<TOptions>.Value is accessed not when IOptions<TOptions> is created. Similar applies for IOptionsSnapshot<TOptions> & IOptionsMonitor<TOptions>. See also https://source.dot.net/#Microsoft.Extensions.Options/OptionsFactory.cs,55.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/configuration/options.md

Document ID

dc7e3449-650b-d117-5eac-69e5ccb250cb

Article author

@tdykstra

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions