Skip to content

Instantly share code, notes, and snippets.

@talkingdotnet
Created February 12, 2018 11:33
Show Gist options
  • Save talkingdotnet/22c08cb5bca2c4dbbacb2b2e657815a5 to your computer and use it in GitHub Desktop.
Save talkingdotnet/22c08cb5bca2c4dbbacb2b2e657815a5 to your computer and use it in GitHub Desktop.
public class ValidateModelStateAttribute : 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