Guest User

Untitled

a guest
Jul 19th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public class Global : HttpApplication
  2. {
  3. protected void Application_OnError()
  4. {
  5. if (Context.IsCustomErrorEnabled && isAjaxRequest())
  6. {
  7. // By default, customErrors will cause a 302 redirect
  8. // We really want a 500 response, so that the client request knows there was an error
  9. error_without_redirect();
  10. }
  11. }
  12.  
  13. private void error_without_redirect()
  14. {
  15. Server.ClearError();
  16. Response.ClearContent();
  17. Response.StatusCode = 500;
  18. Response.StatusDescription = "Internal Server Error";
  19. Response.Write("<html><body><h1>500 Internal Server Error</h1></body></html>");
  20. }
  21.  
  22. private static bool isAjaxRequest()
  23. {
  24. return HttpContext.Current.IsAjaxRequest();
  25. }
  26. }
Add Comment
Please, Sign In to add comment