Created
December 28, 2017 18:25
-
-
Save thiagoloureiro/78817fca7862be8eeb6b484f1fe8a162 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ModelStateValidationActionFilterAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(HttpActionContext actionContext) | |
{ | |
var modelState = actionContext.ModelState; | |
if (!modelState.IsValid) | |
actionContext.Response = actionContext.Request | |
.CreateErrorResponse(HttpStatusCode.BadRequest, modelState); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment