0

I am running FluentValidation (v 8.6.3) along side FluentValidation.WebApi (v 8.6.1) on.Net 4.7.2 WebAPI stack.

Since the system is multitenant, I would like to inject a validation rule per tenant. While from the IoC side that is all wired up already (by implementing the IValidatorFactory), it looks like FluentValidationModelValidatorProvider calls it only once the first time and does not try again, while I need this to be triggered on every request as I determine the tentnat on a per request.

Does anyone know how one can force the validator provider to request factory each time so that it invokes the dependency resolver each time?

Althalus
  • 41
  • 3
  • From what I've read, you are running into an architectural problem with the ASP.NET WebAPI framework. Validators, whether FluentValidation or using component model annotations, are initialized only once on application startup. This was apparently corrected in .NET Core, so the answer might be to convert your project to a .NET Core API project. And that is not necessarily an option sometimes. – Greg Burghardt May 07 '21 at 14:41
  • thank you. Is there a particular service that can be replaced in DnCore? (for future planning) – Althalus May 11 '21 at 08:53

0 Answers0