Guest User

Untitled

a guest
Jan 24th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public class ClientErrorHandler : FilterAttribute, IExceptionFilter
  2. {
  3. public void OnException(ExceptionContext filterContext)
  4. {
  5. var response = filterContext.RequestContext.HttpContext.Response;
  6. response.Write(filterContext.Exception.Message);
  7. response.ContentType = MediaTypeNames.Text.Plain;
  8. filterContext.ExceptionHandled = true;
  9. filterContext.Result = new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  10. }
  11. }
Add Comment
Please, Sign In to add comment