Last active
February 24, 2018 09:41
-
-
Save Ibro/9cd4125a40209b350e08140910d175a5 to your computer and use it in GitHub Desktop.
Validating Model, global filter attribute - https://codingblast.com/asp-net-core-global-model-validation/
This file contains 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 ValidateModelFilter : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext context) | |
{ | |
if (!context.ModelState.IsValid) | |
{ | |
context.Result = new BadRequestObjectResult(context.ModelState); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment