【问题标题】:OperationCanceledException from System.Web.Http.HostAuthenticationFilterSystem.Web.Http.HostAuthenticationFilter 中的 OperationCanceledException
【发布时间】:2015-01-24 06:24:58
【问题描述】:

我们最近检查了我们的错误日志,发现了很多“操作已取消”的异常。 我们无法重现它们,看起来像是一个中止的请求,但它们都来自 OWIN HostAuthenticationFilter。

这是堆栈跟踪:

System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Web.Http.HostAuthenticationFilter.<AuthenticateAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()

以前有人见过这个错误吗?

【问题讨论】:

    标签: asp.net-web-api scheduled-tasks unobserved-exception


    【解决方案1】:

    我知道这个问题已经有一年多了,但我把它留在这里,以防其他人和我有同样的问题。

    是的,这是由取消请求引起的,可能有多种原因,但就我而言,我怀疑您的情况也是如此。 这是由于客户端在服务器响应之前关闭了请求连接。因此服务器取消了不再需要的线程以释放它并抛出异常System.OperationCanceledException

    在这个 StackOverflow 问题半年后创建的 IdentityServer 的 GitHub 上查看这个问题:https://github.com/IdentityServer/IdentityServer3/issues/1698

    是的,听起来用户代理在服务器有机会完成回复之前关闭了它的 HTTP 连接。 - source

    查看这个类似的 StackOverflow 问题,了解如何从记录中捕获这些异常ASP.NET Web API OperationCanceledException when browser cancels the request

    【讨论】:

      猜你喜欢
      • 2012-10-13
      • 2017-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-15
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多