IHttpActionResult如何处理关闭Response对象

时间:2016-06-02 13:33:07

标签: .net asp.net-web-api2

我们已经开始收集众多'远程主机关闭了连接。错误代码是0x800703E3'在过去几天我们的应用程序异常日志中,在研究此错误时,我们的Stack Trace将返回:

at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
   at System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()
   **at System.Web.HttpResponse.Flush(Boolean finalFlush, Boolean async)**
   at System.IO.Stream.<BeginWriteInternal>b__11(Object param0)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.IO.Stream.EndWrite(IAsyncResult asyncResult)
   at Microsoft.Owin.Host.SystemWeb.CallStreams.OutputStream.EndWrite(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Owin.HttpMessageHandlerAdapter.<SendResponseContentAsync>d__20.MoveNext()

我在各种博客和帖子中发现,它建议使用response.end而不是response.flush,但应用程序开发人员正在为所有在内部处理响应对象的控制器使用IHttpRequest。

所以我的问题是,如果IHttpRequest正在处理所有Response对象职责,那么我们是否有任何方式可以优雅地处理这个问题,以便我们不会记录所有这些异常?

TIA, 比尔

0 个答案:

没有答案