Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.