data length is shorter than content-length

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

data length is shorter than content-length

Guest-107
Reply | Threaded
Open this post in threaded view
|

Re: data length is shorter than content-length

Guest-107
I occasionally get an error when uploading that the data length is shorter than the content-length.  Do you know what would cause that?
Reply | Threaded
Open this post in threaded view
|

Re: data length is shorter than content-length

Dean Brettle
Administrator
That exception is thrown whenever NeatUpload does not receive the entire upload.  The most common cause is that the user stops the upload, either via the Cancel button in the progress bar or the Stop button on their browser.  If you are sure that is not the cause, other possibilities are a severed network connection or an insufficent value for the <httpRuntime> executionTimeout attribute.  It defaults to 110 seconds I think.

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: data length is shorter than content-length

Guest-107
ahh ok. thanks.
Reply | Threaded
Open this post in threaded view
|

Re: data length is shorter than content-length

Guest-107

Hello

I am getting this error as well, and have a few questions on how best to handle it. First, you mention a timeout value. I think I have that set quite high as shown below so that's not likely the cause, unless my setting is not getting picked up. Please let me know if setting the timeout this way will not work. Then the request was not cancelled by the user, and it's possible the connection was broken, but I didn't notice any loss of connection for any other page fetches before or after my upload attempts. So I guess my real question is how can I catch this error and go to a page that says "there was a problem uploading.... Please try again". Would this be some custom error that I would add somewhere? Because I have no real code that is controlling the upload, I don't see how I could put a try-catch around anything and catch this exception.

------ in web.config; fileUploader.aspx is the page containing the upload control

<location path="FileUploader.aspx">

<system.web>

<neatUpload useHttpModule="true"/>

<!-- max upload of 500k and max time of 30 min -->

<httpRuntime maxRequestLength="500" executionTimeout="1800"/>

</system.web>

</location>

Thank you very much for your help,

Mike

Reply | Threaded
Open this post in threaded view
|

Re: data length is shorter than content-length

Dean Brettle
Administrator
You need to set the maxRequestLength attribute of the <neatUpload> element in addition to setting the maxRequestLength attribute of the <httpRuntime> element. The value you use should be large enough to accomodate total acceptable size of the upload HTTP request, which will include all files on the form as well as all other visible form fields, hidden form fields, and ViewState (which is stored in a hidden form field).

I suspect the error you are seeing is occuring when someone attempts to upload a file larger than 500KB (or perhaps the file is smaller than 500KB but the rest of the form fields, etc, causes the entire request to be larger than 500KB). Since you didn't set the maxRequestLength attribute of the <neatUpload> element, NeatUpload won't immediately reject uploads which are too large. Instead, ASP.NET will break the connection after about 500KB or so and you'll get the error.

There is no easy way to display an error page on your main window when this error occurs because the connection to the browser's main window has, by definition, been closed at this point. Moreover, there is no way to distinguish between the user pressing the browser's stop button and something else breaking the connection.
Reply | Threaded
Open this post in threaded view
|

Re: data length is shorter than content-length

Guest-107
http://dnnviking.wordpress.com/2008/12/29/data-length-49152-is-shorter-than-content-length-xxx/