Quantcast
Channel: BlogoSfera » payload
Viewing all articles
Browse latest Browse all 10

Custom ActionFilterAttribute does not get called when the json payload is invalid

$
0
0

Trying to return a correct error message instead of the WebAPI default one {"Message":"The request is invalid.","ModelState" when Json deserialzation fails. I implemented my custom ActionFilterAttribute: internal class ValidateModelAttribute : ActionFilterAttribute { public override void OnActionExecuting(HttpActionContext actionContext) { if (!actionContext.ModelState.IsValid) { actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, actionContext.ModelState); } } } } I decorated my Controller method with […]

The post Custom ActionFilterAttribute does not get called when the json payload is invalid appeared first on BlogoSfera.


Viewing all articles
Browse latest Browse all 10

Trending Articles