Hi all Ive been reading through the excellent thread at the top of this forum about uploading large files, I have implemented a version similar but Im having a problem with readEntityBody method of the httpWorkerRequest. When it hits this line in the code,
it hangs for around 30 seconds and then returns 0 bytes in the byte array, I have seen a few posts out and about on the internet where people have the same issue but there doesn't seem to be an answer. I know for a fact that it is not that the there are not
enough bytes left to fill the buffer, so Im not sure exactly whats going wrong. Any help would be much appreciated. Many thanks Dan heres the middle part of my routine for uploading
If hwr.HasEntityBody Then fileLen = CType(hwr.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength), Integer) progress.bytesTotal = fileLen buffer = hwr.GetPreloadedEntityBody fStream.Write(buffer, 0, buffer.Length) recieved = buffer.Length totalLen
+= recieved progress.bytesReceived = totalLen If Not hwr.IsEntireEntityBodyIsPreloaded Then ReDim buffer(buffsize) bytesRemaining = fileLen - recieved While bytesRemaining >= buffer.Length recieved = hwr.ReadEntityBody(buffer, buffer.Length) fStream.Write(buffer,
0, recieved) totalLen += recieved progress.bytesReceived = totalLen End While recieved = hwr.ReadEntityBody(buffer, (fileLen - totalLen)) fStream.Write(buffer, 0, recieved) totalLen += recieved progress.bytesReceived = totalLen End If
I know this is an old thread, but I've had this problem very recently and wanted to help anyone else who finds this in Google.
The problem was that we have code similar to the above in a C# HttpHandler. It worked fine on its own, but when I attempted to integrate my Uploader into our product it stopped working.
The problem in our case was that a HttpModule was requesting a parameter from the HttpContext.request object and this was causing ASP.Net to process the request, uploading the file in the process, before my Upload code had even been hit.
This causes the EntityBody to get cleared out, and 'by the way' negated the whole purpose of the Uploader! We made a case so that it wouldn't request this variable if the request was for the Upload HttpHandler, and it started working straight away.
I second this. Have just wasted an hour with an httpmodule that used to work and wasn't during debugging. The reason: I hadn't noticed context.Request.Files was in the debug watch window from a previous debug session!
Worth noting that it seems fine to access some Request properties such as Headers[], ContentLength etc.
None
0 Points
29 Posts
HttpWorkerRequest readEntityBody returns 0 bytes
Sep 09, 2003 01:28 PM|dannyboy78|LINK
If hwr.HasEntityBody Then fileLen = CType(hwr.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength), Integer) progress.bytesTotal = fileLen buffer = hwr.GetPreloadedEntityBody fStream.Write(buffer, 0, buffer.Length) recieved = buffer.Length totalLen += recieved progress.bytesReceived = totalLen If Not hwr.IsEntireEntityBodyIsPreloaded Then ReDim buffer(buffsize) bytesRemaining = fileLen - recieved While bytesRemaining >= buffer.Length recieved = hwr.ReadEntityBody(buffer, buffer.Length) fStream.Write(buffer, 0, recieved) totalLen += recieved progress.bytesReceived = totalLen End While recieved = hwr.ReadEntityBody(buffer, (fileLen - totalLen)) fStream.Write(buffer, 0, recieved) totalLen += recieved progress.bytesReceived = totalLen End If
None
0 Points
1 Post
Re: HttpWorkerRequest readEntityBody returns 0 bytes
Sep 24, 2003 01:56 AM|BrianJ|LINK
None
0 Points
3 Posts
Re: HttpWorkerRequest readEntityBody returns 0 bytes
Aug 27, 2009 06:33 AM|Russc|LINK
Hi,
I know this is an old thread, but I've had this problem very recently and wanted to help anyone else who finds this in Google.
The problem was that we have code similar to the above in a C# HttpHandler. It worked fine on its own, but when I attempted to integrate my Uploader into our product it stopped working.
The problem in our case was that a HttpModule was requesting a parameter from the HttpContext.request object and this was causing ASP.Net to process the request, uploading the file in the process, before my Upload code had even been hit.
This causes the EntityBody to get cleared out, and 'by the way' negated the whole purpose of the Uploader! We made a case so that it wouldn't request this variable if the request was for the Upload HttpHandler, and it started working straight away.
Good luck!
Member
30 Points
21 Posts
Re: HttpWorkerRequest readEntityBody returns 0 bytes
Jul 14, 2011 05:32 AM|Jai B|LINK
I second this. Have just wasted an hour with an httpmodule that used to work and wasn't during debugging. The reason: I hadn't noticed context.Request.Files was in the debug watch window from a previous debug session!
Worth noting that it seems fine to access some Request properties such as Headers[], ContentLength etc.