Skip to content

Instantly share code, notes, and snippets.

@Ibro
Last active February 24, 2018 09:41
Show Gist options
  • Save Ibro/9cd4125a40209b350e08140910d175a5 to your computer and use it in GitHub Desktop.
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/
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