I added this to my web.config
file:
<httpRuntime maxRequestLength="40960"/> <!-- Limit to 40 megabytes -->
And when I try to upload something bigger than 40 megabytes, I get this in Firefox:
The connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try again in a few
moments.
* If you are unable to load any pages, check your computer's network
connection.
* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.
Is there some way to also benefit from this built in file size limitation but actually show a nice error page? Of course I could do this check in the controller but at that point the traffic is already spent because the huge file has reached my server.
if (image.ContentLength > 40960) // 'image' is HttpPostedFileBase
Any suggestions?
How about this in your global.asax.cs?