SHARE
TWEET

Untitled

a guest Aug 14th, 2019 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ModelStateFilter : ActionFilterAttribute
  2.     {
  3.         public override void OnActionExecuting(ActionExecutingContext context)
  4.         {
  5.             if (!context.ModelState.IsValid)
  6.             {
  7.                 context.Result = new BadRequestObjectResult(new
  8.                 {
  9.                     Error = "My custom error message"
  10.                 });
  11.             }
  12.         }
  13.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top