Handling maxRequestLength errors in IIS6
-
Hi there, I'm facing a problem with limiting the file upload size in ASP.NET 2.0, or more specifically, by handling "file too large" errors. I did the development & testing on a Vista Business / IIS 7, where I was able to handle the situation nicely using the Application_Error handler in global.asax. When the uploaded file size is larger than maxRequestLength, I just displayed a friendly error page with explanation. After deploying the application to the production server, which is running Windows 2003 R2 with IIS 6, I realized that this doesn't work. What's worse, in case the file is larger than the limit, it won't display any error message, IIS simply cuts off the connection and browsers display their own error message about the network connection being interrupted. Is there any solution to this problem on IIS 6? All my googling points to websites suggesting the Application_Error handler, or eventually configuring a custom error page in IIS directly, but none of this will work if IIS 6 just cuts off the connection. Also, it does this right in the beginning - i.e. I try to upload a 4MB file and it cuts me off after 5 seconds, not after transferring 2MB (which is my current limit, note that the server is remote and I have 256kbit upload) so it must know about the filesize from the start. I'd like to be able to handle this in a friendlier matter, in a simple way (i.e. handling in .NET code, or by configuring error page in IIS). I know that there are flash uploaders, etc, but those are out of question right now. Any clues or ideas are highly appreciated! Thanks, Rado
-
Hi there, I'm facing a problem with limiting the file upload size in ASP.NET 2.0, or more specifically, by handling "file too large" errors. I did the development & testing on a Vista Business / IIS 7, where I was able to handle the situation nicely using the Application_Error handler in global.asax. When the uploaded file size is larger than maxRequestLength, I just displayed a friendly error page with explanation. After deploying the application to the production server, which is running Windows 2003 R2 with IIS 6, I realized that this doesn't work. What's worse, in case the file is larger than the limit, it won't display any error message, IIS simply cuts off the connection and browsers display their own error message about the network connection being interrupted. Is there any solution to this problem on IIS 6? All my googling points to websites suggesting the Application_Error handler, or eventually configuring a custom error page in IIS directly, but none of this will work if IIS 6 just cuts off the connection. Also, it does this right in the beginning - i.e. I try to upload a 4MB file and it cuts me off after 5 seconds, not after transferring 2MB (which is my current limit, note that the server is remote and I have 256kbit upload) so it must know about the filesize from the start. I'd like to be able to handle this in a friendlier matter, in a simple way (i.e. handling in .NET code, or by configuring error page in IIS). I know that there are flash uploaders, etc, but those are out of question right now. Any clues or ideas are highly appreciated! Thanks, Rado
Did you set the values in web.config for upload ?
cheers, Abhijit My Recent Article : Beginner's Guide To ASP.Net Cookies
-
Did you set the values in web.config for upload ?
cheers, Abhijit My Recent Article : Beginner's Guide To ASP.Net Cookies
But of course - as I said in my original post all works well on IIS 7. The maxRequestLength is set to 2048 (2MB) and executionTimeout to 2 minutes. Thanks!
-
Hi there, I'm facing a problem with limiting the file upload size in ASP.NET 2.0, or more specifically, by handling "file too large" errors. I did the development & testing on a Vista Business / IIS 7, where I was able to handle the situation nicely using the Application_Error handler in global.asax. When the uploaded file size is larger than maxRequestLength, I just displayed a friendly error page with explanation. After deploying the application to the production server, which is running Windows 2003 R2 with IIS 6, I realized that this doesn't work. What's worse, in case the file is larger than the limit, it won't display any error message, IIS simply cuts off the connection and browsers display their own error message about the network connection being interrupted. Is there any solution to this problem on IIS 6? All my googling points to websites suggesting the Application_Error handler, or eventually configuring a custom error page in IIS directly, but none of this will work if IIS 6 just cuts off the connection. Also, it does this right in the beginning - i.e. I try to upload a 4MB file and it cuts me off after 5 seconds, not after transferring 2MB (which is my current limit, note that the server is remote and I have 256kbit upload) so it must know about the filesize from the start. I'd like to be able to handle this in a friendlier matter, in a simple way (i.e. handling in .NET code, or by configuring error page in IIS). I know that there are flash uploaders, etc, but those are out of question right now. Any clues or ideas are highly appreciated! Thanks, Rado
Hi, please try to extend the maxrequestlength in web.config to 5MB or greater, you can extend upto 2 GB for a 2.0 application. Please revert back if the problem still exists. Thanks, Rajdev
-
Hi, please try to extend the maxrequestlength in web.config to 5MB or greater, you can extend upto 2 GB for a 2.0 application. Please revert back if the problem still exists. Thanks, Rajdev
Thanks, but actually, I need to limit file upload size (and handle it in a friendly manner) that's why I set this to 2MB so this would not resolve anything. Btw I did not find any solution to this - it seems to me that it's not possible to handle this in IIS6, whereas it works nicely in IIS7.
-
Thanks, but actually, I need to limit file upload size (and handle it in a friendly manner) that's why I set this to 2MB so this would not resolve anything. Btw I did not find any solution to this - it seems to me that it's not possible to handle this in IIS6, whereas it works nicely in IIS7.
Hi, We have faced a similar issue and resolved it. Please find the instructions we followed to resolve. We have limited the upload size to 10MB and we are showing friendly message if the size exceeds. Please revert back if you still have the issue.Thanks. Root Cause of the Issue · IIS6 uses a new metabase property called UploadReadAheadSize when passing data to an ISAPI extension. This property is used to determine the maximum buffer size for the incoming request. The default size for this buffer is 48k · If UploadReadAheadSize is smaller than the content length, an HTTP 413error is returned, and the connection is closed to prevent deadlock. This causes the “Page cannot be displayed” error in IE Solution · Change the value of UploadReadAheadSize to a value larger than the content length · The following example shows how to set the value for UploadReadAheadSize to 200KB on the Web server cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 200 Source http://technet.microsoft.com/en-us/library/cc737382.aspx http://blogs.msdn.com/jiruss/archive/2007/04/13/http-413-request-entity-too-large-can-t-upload-large-files-using-iis6.aspx Thanks, Rajdev