This code transfers large files to our users:
// Open the file. iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); // Total bytes to read: dataToRead = iStream.Length; // Read the bytes. while (dataToRead > 0) { // Verify that the client is connected. if (Response.IsClientConnected) { // Read the data in buffer. length = iStream.Read(buffer, 0, 10000); // Write the data to the current output stream. Response.OutputStream.Write(buffer, 0, length); // Flush the data to the HTML output. Response.Flush(); buffer = new Byte[10000]; dataToRead = dataToRead - length; } else { //prevent infinite loop if user disconnects dataToRead = -1; } }
From time to time we get this exception:
The remote host closed the connection. The error code is 0x80072746
Here is the full stack trace:
Stack Trace: at System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.FlushCore(Byte[] status, Byte[] header, Int32 keepConnected, Int32 totalBodySize, Int32 numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32 doneWithSession, Int32 finalStatus, Boolean& async) at System.Web.Hosting.ISAPIWorkerRequest.FlushCachedResponse(Boolean isFinal) at System.Web.Hosting.ISAPIWorkerRequest.FlushResponse(Boolean finalFlush) at System.Web.HttpResponse.Flush(Boolean finalFlush) at System.Web.HttpResponse.Flush() at System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size) at System.Web.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count) at BIS.DocumentBus.Controls.DocumentViewer.StreamFile(String filepath)
We have never had evidence that users are having trouble downloading our files and plan to simply ignore this exception.
Any idea what is the source of this problem? Is it safe to ignore?
spaetzel May 6 '09 at 19:57 2009-05-06 19:57
source share