We recently tried to include Response.IsClientConnected in our asp.net site, but it causes seemingly random exceptions that only appear when checking this property. If we comment on this code, we will stop receiving exceptions. We get a ton of items in our log file, indicating that our clients are disabled, and we are still processing, so this is clearly an opportunity for optimization, but we need to find out what happens with the exceptions in the first place. Any idea what causes this exception, and how can we get around it?
Our site is hosted on Windows Server 2008 r2 x64 with IIS 7.5 and .NET 4.5.
If Not Response.IsClientConnected Then
' write to log file
End If
We get the following exception (again, it would seem, random and only when we have the IsClientConnected check live on our site):
System.Runtime.InteropServices.COMException (0x800703E3): The I / O operation was interrupted due to a stream or application request. (Exception from HRESULT: 0x800703E3)
UPDATE
We also get another, but error-related, much higher frequency whenever an IsClientConnected check is turned on. I was able to increase our error logs to get a full stack trace (see below). The error occurs before it gets into our code. I assume that this is because the user sends back the page and takes a lot of time (possibly due to loading the image), and the user cancels the request before IIS has the opportunity to pack everything and pass it our code.
What can we do about this?
And why does the frequency with which we receive these errors increase when we have an IsClientConnected check, although this line of code never gets because the request never entered our code?
Error message
System.Web.HttpException: Specified method is not supported.
Stack trace
[NotSupportedException: Specified method is not supported.]
at System.Web.HttpResponseStream.get_Position()
at System.Drawing.UnsafeNativeMethods.ComStreamFromDataStream.Seek(Int64 offset, Int32 origin)
[HttpException: An error occurred while communicating with the remote host. The error code is 0x800703E3.]
at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
at System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(Byte[] buffer, Int32 offset, Int32 size)
at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.EnsureForm()
at System.Web.HttpRequest.get_Form()
at Aurigma.ImageUploaderFlash.UploaderModule.context_BeginRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Error message
System.Web.HttpException: The I/O operation has been aborted because of either a thread exit or an application request. (Exception from HRESULT: 0x800703E3)
Stack trace
[COMException: The I/O operation has been aborted because of either a thread exit or an application request. (Exception from HRESULT: 0x800703E3)]
[HttpException: An error occurred while communicating with the remote host. The error code is 0x800703E3.]
at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
at System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(Byte[] buffer, Int32 offset, Int32 size)
at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.EnsureForm()
at System.Web.HttpRequest.get_Form()
at Aurigma.ImageUploaderFlash.UploaderModule.context_BeginRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)