I'm attempting to upload documents to my server using the technique describe on this blog
All has gone well, and I am able to upload documents just fine. The only snag is when I attempt to upload a file which exceeds the upload limit which is defined in my web.config as so....
<location path="Documents/Documents/Add">
<system.web>
<httpRuntime maxRequestLength="25600"/>
</system.web>
</location>
The problem is that I am not getting a response from the server. In fact, when debugging in Visual Studio, the action is not even hit!
Further investigation in fiddler shows that I'm getting a...
504: ReadResponse() failed: The server did not return a response for this request.
....but I am only getting this in Chrome when fiddler is running. If fiddler isn't running chrome simply sees "Failed" with no status code, and the error() of the $().ajax form call isn't hit.
Also this SO post has exactly the same issue. However, I want to know how I can give feedback to the user when the file size is exceeded as currently the "loading.gif" is just spinning as no error response is being raised.
Check this SO question about client side checking of file size to be able to catch it before trying to upload a file that is too big. Find size of file behind download link with jQuery
EDIT
The server will throw an exception if the filesize is larger than your setting in the web.config file so you can do a couple things if you want to handle it server side.
1) You can increases the max file size and then your upload code can validate a smaller size and return a failure if it is too large. Of course if they try for something even bigger than your new size it will still fail.
2) Catch the error in the global.asax file and do something with it. Set a response header, return false or whatever. Check Catching "Maximum request length exceeded" to get you started on this option.
3) Handle it client side with the JQuery option I put up earlier or use Flash to check the size.
Basically waiting for the server to tell you the file is too large is usually too late. The file has to go all the way there before it can tell you oops too big. This incurs a larger hit on your server. It is usually better to find a way to check it on the client if possible.