Created
January 12, 2011 20:28
-
-
Save KevM/776816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Global : HttpApplication | |
| { | |
| protected void Application_OnError() | |
| { | |
| if (Context.IsCustomErrorEnabled && isAjaxRequest()) | |
| { | |
| // By default, customErrors will cause a 302 redirect | |
| // We really want a 500 response, so that the client request knows there was an error | |
| error_without_redirect(); | |
| } | |
| } | |
| private void error_without_redirect() | |
| { | |
| Server.ClearError(); | |
| Response.ClearContent(); | |
| Response.StatusCode = 500; | |
| Response.StatusDescription = "Internal Server Error"; | |
| Response.Write("<html><body><h1>500 Internal Server Error</h1></body></html>"); | |
| } | |
| private static bool isAjaxRequest() | |
| { | |
| return HttpContext.Current.IsAjaxRequest(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment