Skip to content

Is there a way to get AddOptionsWithValidateOnStart to work in Blazor Web Assembly? #62649

Answered by philipmorley
philipmorley asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks, it looks like you have to actually call the options to get the validator to fire. I modified your example slightly:

var foo = host.Services.GetRequiredService<IOptions>();
var bar = foo.Value.Bar;

And when I did this I got the 'Unhandled error has occurred...' error to appear on startup. It's a little bit ugly to have that unused bar variable in my startup code, but I can live with this as a workaround.

Thanks for your help.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@philipmorley
Comment options

Answer selected by philipmorley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants