Has anybody succeeded in catching and handling the 'maximum length exceeded
error' that occurs when someone tries to upload a file larger than allowed
by the setting in web.config?
I want to display a useful error message and have the user redirected back
to the upload page instead of showing the standard error page.
I've tried putting error handling code into Sub Application_Error(ByVal
sender As Object, ByVal e As EventArgs) global.asax. My routine does indeed
get called, but the error keeps popping up, even after the call to
Server.ClearError, and I get redirected to my error page or receive a
notification that the page could not be found. When I trace my web app, the
maximum request length exceeded error is raised, then the Application_Error
routine is executed and immediately afterwards, the "maximum request length
exceeded error" is raised again (and the Application_Error routine is
executed a second time).
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Fires when an error occurs
Dim ex As System.Exception = Server.GetLastError
Do
If TypeOf ex Is System.Web.HttpException And _
ex.Message = "Maximum request length exceeded." Then
Server.ClearError()
Response.Redirect(HttpContext.Current.Request.RawUrl & "&e=1")
Exit Sub
End If
ex = ex.InnerException
Loop Until IsNothing(ex)
End Sub
Does anyone know how to effectively clear the error or has anybody had more
luck with a different approach?
Any help would be greatly appreciated
Bernt Fischer
netMEDIA AG
Software Engineer
--
have a nice day
Antonin Foller
PSTRUH Software
http://www.pstruh.cz
"Bernt Fischer" <bfis...@netmedia1.com> wrote in message
news:uNR$4T00CHA.1644@TK2MSFTNGP12...