MVC5 integration
I am on SS 4.0.19 at present for all my web services.
We are adding a MVC5 web site to our solution and we use servicestack (AppHost, + SSFunq as our IoC) etc on this MVC site to call our services.
We now want to integrate FluentValidation (FV) into the MVC site and replace DataAnnotations to validate our ViewModels.
I known FV supports MVC5 (in a dedicated NuGet) and we got that working just fine, but there is much overlap (duplicate types) now with ServiceStack internal version of FV.
I notice that the ServiceStack.Mvc package is still only supporting MVC3.
Is there any option here where I can replace FV with a Signed ServiceStack NuGet that will support MVC5?
I think the only thing we are missing from SS at present is the ability to register validation for MVC to use FV like this:
FluentValidationModelValidatorProvider.Configure(provider =>
{
provider.ValidatorFactory = new FunqValidatorFactory(container);
});
Fluent Validation is internalized and tightly integrated with ServiceStack’s validation and error handling, it’s not something that can be swapped out.
There’s a UseCase project that uses MVC5 with SS here:
https://github.com/ServiceStack/ServiceStack.UseCases/tree/master/Mvc5
It seems you should be able to use SS.Mvc and MVC5 together as-is.
Jezz Santos:
Thanks Demis, but this project (as an example) uses DataAnnotations as the validation framework, whereas I want to replace that with FluentValidation, which is why I need the code above, which evidently only works for MVC3 (according to posts I have trawled through).
However, I will try using SS.MVC (as long as I can find a signed version somewhere)! Else I am going to have to copy out the classes I need from FV.MVC5 into my codebase as the last resort.
Jezz Santos:
Reporting back. I can confirm the following method works for me, for anyone with the same issue coming after.
I absorbed the code (15 source files) from FluentValidation.Mvc5 into my web project, and adjusted (only using statements) it to use ServiceStack.FluentValidation.*.
It works a brilliant treat. Now I can eliminate the FluentValidation assemblies and NuGet from my entire solution. (avoid duplicate types in different namespaces)
Downside is that I wont receive updates to FV.Mvc, but that can be managed manually due to small size of footprint.