Is there a way to get AddOptionsWithValidateOnStart to work in Blazor Web Assembly? #62649
Unanswered
philipmorley
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Given:
I am trying to validate the appsettings.json file of my client web project using AddOptionsWithValidateOnStart.
Here is the client project wwwroot/appsettings.json:
And FooSettings.cs:
And Program.cs:
I was expecting/hoping that when I run the application I get an exception complaining that the Bar setting was missing. Instead I can navigate around the Home/Counter/Weather pages without error.
If I inject FooSettings into a page, for example:
Then I do get the desired behaviour when I navigate to the Counter page. How I can I get this behaviour across the entire website?
Demo repo here: https://github.com/philipmorley/BlazorValidateOptions
Beta Was this translation helpful? Give feedback.
All reactions