In my web.config, I have the file upload size limited to 10 MB:
<httpRuntime maxRequestLength="10000" /> <!-- file size limit in KB -->
On my page, I'm checking to see that the user doesn't upload a file larger than 5 MB:
protected void cvImageSize_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = (fupFile.PostedFile.InputStream.Length <= 5000000);
}
If a user tries to upload a 3 MB file, it uploads fine. If a user tries to upload a 7 MB file, they are shown the error message from cvImageSize.
If a user tries to upload a 13 MB file...the site crashes. I'm not sure exactly what happens, Firefox gives me the page saying "The connection was reset. The connection to the server was reset while the page was loading."
Is there some exception I can catch when the user tries to upload a file with a size greater than the maxRequestLength? I'd like to show the user an error message on the page instead of the site basically crashing.