“The remote host closed the connection” in Response.OutputStream.Write

前端 未结 4 1538
清酒与你
清酒与你 2020-12-28 15:31

This code streams large files to our users:

                // Open the file.
            iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Ope         


        
4条回答
  •  梦毁少年i
    2020-12-28 15:35

    That exception means that the client downloading the file broke the connection before the file had finished downloading. i.e. The client navigated to another page, or just closed the browser.

    I might try moving the if (Response.IsClientConnected) line after your iStream.Read. Even if you did that, I think there still might be a chance to receive this error if the connection is broken while the OutputStream.Write method is still working.

提交回复
热议问题