This one has been bugging me all day. Usually I try to catch as many errors as possible in each page. However because I have an upload form, and if the file uploaded is larger than the server limit (4MB by default) it will cause an application error, the page never fires. So I cant test for size in the page itself. So I googled a solution, to which I was told to catch the error in Application_Error in my global.asax page, then clear the error and redirect back to the upload form to show an error message.
Well as far as I can tell, the Application_Error is not getting fired at all. If I put bad code in there, I get a compile error, so at least the server is trying to compile it. But if I strip it down to just this, i get nothing
but instead I still just get the same error page I was getting before:
Well as far as I can tell, the Application_Error is not getting fired at all. If I put bad code in there, I get a compile error, so at least the server is trying to compile it. But if I strip it down to just this, i get nothing
Code:
void Application_Error(object sender, EventArgs e)
{
throw new Excpeption("got here");
}
Server Error in '/' Application.
--------------------------------------------------------------------------------
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Maximum request length exceeded.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +3315874
System.Web.HttpRequest.GetMultipartContent() +56
System.Web.HttpRequest.FillInFormCollection() +244
System.Web.HttpRequest.get_Form() +65
System.Web.HttpRequest.get_HasForm() +57
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +2070529
System.Web.UI.Page.DeterminePostBackMode() +63
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133