I'm using ServiceStack + FluentValidation v3.
I can post directly to the API and experience request validation, however, when calling from a resolved service instance in my MVC controller, no validation is triggered.
Using Fiddler, I POST
the following:
POST /api/json/oneway/FieldSample HTTP/1.1
Content-Type: application/json
Content-Length: 66
Host: localhost:53185
{"Sample.Id":"2866246","Sample.SampleTime":"6/7/1950 12:00:00 PM"}
Response, as desired:
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Content-Length: 138
Connection: Close
{"responseStatus":{"errorCode":"LessThan","message":"TestTest","errors":[{"errorCode":"LessThan","fieldName":"Id","message":"TestTest"}]}}
From my MVC Controller:
using (var svc = AppHostBase.ResolveService<FieldSampleService>(System.Web.HttpContext.Current))
{
try { svc.Post(model.Sample); }
catch (WebServiceException webEx)
{
return Json(new { Success = false }, "text/html");
}
}
No exception is thrown.
Manually creating an instance of the IValidator in the Service and throwing the exception DOES bubble the exception.
Why is the validation not triggering against requests originating from the AppHostBase.ResolveService
?