Hello.
I've got a page that lets you upload files. I've increased the maximum filesize to the desired level and that works but I would like to have customised error handling for when the user uploads something too big.
All the guides I've found so far give advice on how to redirect to a specal error page, I can't find anything on how to just present the error in a current page. Here's what I'm using so far.
protected override void OnError(EventArgs e)
{
HttpContext hcCurrentContext = HttpContext.Current;
Exception eException = this.Server.GetLastError();
if (eException.Message.Equals("Maximum request length exceeded."))
{
hcCurrentContext.Server.ClearError();
tbErrorMessage.Text = "File too large";
tbErrorMessage.Visible = true;
}
else
{
base.OnError(e);
}
}
I ran it through a debugger and it does go into the If clause correctly, but I still get redirected to the default FireFox error page with the message "The connection to the server was reset while the page was loading". Can anyone advise me?