How to handle "Maximum request length exceeded" exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have changed my config files to set the limit for files being uploaded to
30 MB, but every now and then someone tries to upload a file larger than this.

All I want, is to be able to trap the error and tell the user what happened.

I can trap the error in the page_error (Page.Error) event, and I believe I
was also trapping it at the application_error level at one point.

My problem is, once I trap the error, I can't do anything to tell the user
what happened. If I try to display an error message in a asp.net label, or
response.write some text, or response.redirect them to another page, or just
set the errorPage property for the upload page to some URL, none of these
work.

When you upload a large file, the error is trapped correctly, and then the
browser shows the "Page cannot be displayed" message, no matter which of the
methods above I have tried.

Can anyone help me with this one?
 
If the file is too large, an ugly error screen will be displayed to the user
and as far as I know there's nothing you can do about this without some kind
of thick client.

So to solve your problem, you might look into using a 3rd party activex
control such as this:
http://fileup.softartisans.com/fileup-231.aspx
 
Steve,

Thanks for the reply.

I'm guessing that the reason I am not getting the normal ASP.NET error
page because I have error trapping at the page and application level.
So there is not an unhandled exception.

What I don't understand is why it seems like I can no longer relay
anything to the user once this error has occurred. I am wondering if
this is something to do with the nature of the exception, meaning that
the browser thinks it is still uploading the file (over the max amount)
while the server has already thrown the exception and stopped accepting
the upload?

I understand that this max input is put in place for security reasons,
but I can't believe that there is no way to display an error message to
the user, or direct them to an error page, in the event that they
exceed the maximum size for an upload.

If ASP.NET can give the user an ugly error page when this happens, I
should be able to give them a nice error page.

I understand that an ActiveX control would make this a lot easier, but
that is not an option for me for the obvious reasons.

Any idea where I can find more about this problem, or what I need to do
to give my users a nice error page?

Chris
 
Back
Top