asp.net mvc - NinjectValidatorFactory is creating multiple instances of a validator -
i trying use ninject fluentvalidation , having weird issue -- when submit form, constructor validator being called 32 (!) times. if remove configuration, constructor called once (but of course no injection takes place). thing can think of should setting factory somewhere other ninjectwebcommon, don't see anywhere else have access kernel so.
any ideas why validator firing many times?
in registerservices() in ninjectwebcommon.cs:
ninjectvalidatorfactory ninjectvalidatorfactory = new ninjectvalidatorfactory(kernel); fluentvalidationmodelvalidatorprovider.configure(provider => provider.validatorfactory = ninjectvalidatorfactory); dataannotationsmodelvalidatorprovider.addimplicitrequiredattributeforvaluetypes = false;
in validation resolver:
assemblyscanner.findvalidatorsinassemblycontaining<cleanupsitevalidator>() .foreach(match => bind(match.interfacetype).to(match.validatortype));
edit: added inrequestscope()
resolver , constructor validator fires once, createinstance()
in ninjectvalidatorfactory.cs
still firing 32 times. suppose is...better, should factory called many times? seems there still wrong.
assemblyscanner.findvalidatorsinassemblycontaining<cleanupsitevalidator>() .foreach(match => bind(match.interfacetype).to(match.validatortype).inrequestscope());
Comments
Post a Comment