Response.IsClientConnected导致异常

时间:2015-06-15 21:05:45

标签: asp.net iis-7.5 comexception

我们最近尝试将Response.IsClientConnected合并到我们的asp.net网站中,但它会导致看似随机的异常,只有在我们检查此属性时才会显示。如果我们注释掉该代码,我们就会停止获取异常。我们在日志文件中收到大量项目,表明我们已断开客户端并且我们仍在进行处理,因此显然是优化的机会,但我们需要先了解异常情况。知道造成这种异常的原因以及我们如何解决这个问题?

我们的网站托管在Windows Server 2008 r2 x64上,包含IIS 7.5和.NET 4.5。

If Not Response.IsClientConnected Then
    ' write to log file
End If

我们收到以下异常(再次,看似随机,只有当我们在我们的网站上检查IsClientConnected时):

System.Runtime.InteropServices.COMException(0x800703E3):由于线程退出或应用程序请求,I / O操作已中止。 (HRESULT异常:0x800703E3)

更新

每当我们检查IsClientConnected是否打开时,我们也会得到一个不同但相关的错误频率更高的错误。我能够增加我们的错误日志以获得完整的堆栈跟踪(见下文)。错误发生在它甚至到达我们的代码之前。我猜这是因为用户正在回发页面并且花费很长时间(可能是因为图片上传)并且用户在IIS有机会打包所有内容并将其交给以后取消请求我们的代码。

我们能做些什么呢?

当我们进行IsClientConnected检查时,为什么我们得到这些错误的频率会增加,即使这段代码永远不会被命中,因为请求从未进入我们的代码?

错误消息

System.Web.HttpException: Specified method is not supported.

堆栈跟踪

[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)

错误消息

System.Web.HttpException: The I/O operation has been aborted because of either a thread exit or an application request. (Exception from HRESULT: 0x800703E3)

堆栈跟踪

[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)

0 个答案:

没有答案