Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File upload: How to catch 'maximum length exceeded' error

36 views
Skip to first unread message

Bernt Fischer

unread,
Feb 13, 2003, 4:48:12 AM2/13/03
to
Hi

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


Antonin Foller

unread,
Feb 15, 2003, 4:38:36 AM2/15/03
to
Hi, Bernt
The problem is with IIS UploadReadAheadSize property probably. See notes
about the property and uploads at
http://www.pstruh.cz/help/scptutl/pa35.htm


--
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...

0 new messages