I am using Visual Studio 2010/ASP.NET/C-Sharp website.
I basically had an ASP.NET FileUpload control, for which I needed to cater the exception thrown for the following message:-
Maximum request length exceeded.
The maximum file size setting is set in the web.config as follows:-
<httpRuntime maxRequestLength="40960" requestValidationMode="2.0" />
Using Global.asax with validating file size in "Application_Error()", but it has not resolved my issue and it crashes at the Redirect when file size is greater and a redirect to Error Page is not working.
I have used the following code, although it is now running the Application_Error() Code section, but the problem is that it is not redirecting to the About.aspx page.
void Application_Error(object sender, EventArgs e)
Exception exc = Server.GetLastError();
if (exc.Message.Contains("Maximum request length exceeded"))
if (exc.InnerException.Message.Contains("Maximum request length exceeded"))
catch (Exception ex)
I want to find out that how can I accomplish my requirements, since I am stuck for this since a couple of days.
Kindly help me in this regards as early as possible.