-
Hello everyone, we're on .NET Core 3.1.5 and this is a Blazor Server application. We have a ValidationAttribute has the
This was raised (and fixed) back in Mvc: aspnet/Mvc#6346
And later down the stack the service provider is also never set. Any Google search eventually ends up at this Blog post but as I just mentioned this doesn't work. So our question is: What's the correct way of injecting services into a ValidationAttribute or more general what is the proper way to validate a field of a model that requires a call to an external service? Also: I'm using C#/.NET for the first time in 15 or so years, please be gentle ;-) Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For anyone stumbling across this later: A colleague asked the same question on StackOverflow and received an answer here: https://stackoverflow.com/questions/62559817/how-to-get-inject-services-in-custom-validationattributes Short version is: Subscribe to the |
Beta Was this translation helpful? Give feedback.
For anyone stumbling across this later: A colleague asked the same question on StackOverflow and received an answer here: https://stackoverflow.com/questions/62559817/how-to-get-inject-services-in-custom-validationattributes
Short version is: Subscribe to the
OnFieldChanged
event of the Form'sEditContext
instead.