- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用最新版本的 WebAPI。我的 WebAPI 返回 RSS 提要数据。我用 blitz 做了一个负载测试,下面是它的结果。
This rush generated 115,908 successful hits in 300 seconds and we transferred 1.91 GB of data in and out of your app. The average hit rate of 386.36/second translates to about 33,381,504 hits/day. The average response time was 410 ms. You've got bigger problems, though: 0.87% of the users during this rush experienced timeouts or errors!
返回 RSS 的 WebAPI 代码如下。它使用来自 https://github.com/filipw/AspNetWebApi-OutputCache 的 OutPutCache 库
[AllowAnonymous]
[CacheOutput(ServerTimeSpan = 14400)]
[HttpGet]
public async Task<HttpResponseMessage> GetRssData()
{
string responseFromServer = string.Empty;
WebRequest request = WebRequest.Create("URL FOR MY RSS FEED HERE");
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream dataStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(dataStream))
{
responseFromServer = await reader.ReadToEndAsync();
}
}
}
return new HttpResponseMessage() { Content = new StringContent(responseFromServer, Encoding.UTF8, "application/rss+xml") };
}
下面是同样的错误日志
Exception information: Exception type: OperationCanceledException Exception message: The operation was canceled. at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at System.Web.Http.WebHost.HttpControllerHandler.d__1b.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.WebHost.HttpControllerHandler.d__7.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.WebHost.HttpControllerHandler.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.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)Thread information:
Stack trace: at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at System.Web.Http.WebHost.HttpControllerHandler.d__1b.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.WebHost.HttpControllerHandler.d__7.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.WebHost.HttpControllerHandler.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.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
最佳答案
这看起来像是已取消的请求,被 Web API 自动取消。您通常可以忽略这些错误(从 Web API 5.2 开始,它们不会出现在全局错误处理中)。
关于asp.net-mvc - 操作被取消。在 System.Threading.CancellationToken.ThrowIfCancellationRequested(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23460293/
我有以下代码: CancellationTokenSource cts = new CancellationTokenSource(); ParallelOptions po = new Parall
我目前正在使用 Moq 来帮助我进行单元测试,但是我遇到了一个我不知道如何解决的问题。 例如,假设我想验证 CancellationToken.ThrowIfCancellationRequested
这段代码执行时 cancellationToken.ThrowIfCancellationRequested(); try catch block 不处理异常。 public Enumerab
我有以下代码运行时不会抛出异常: var t = Task.Factory.StartNew(() => LongRunningMethod(cancellationToken, pr
通常我不会发布带有答案的问题,但这次我想引起一些人对我认为可能是一个晦涩但普遍的问题的关注。它是由 this question 触发的,从那以后我检查了我自己的旧代码,发现其中一些也受此影响。 下面的
我有一个任务要取消。 执行此操作的常规方法是使用 CancellationToken . this.task = new SpecialTask(() => { for (int i = 0;
我有来自“.NET Framework 并行编程示例”的以下代码 MSDN当我试图在 Debug模式下取消猴子的遗传生成时,我在 token.ThrowIfCancellationRequested(
我正在尝试迁移到使用 .NET 中的 CancellationToken/Src 结构,例如:https://learn.microsoft.com/en-us/dotnet/standard/thr
我正在使用最新版本的 WebAPI。我的 WebAPI 返回 RSS 提要数据。我用 blitz 做了一个负载测试,下面是它的结果。 This rush generated 115,908 succe
我是一名优秀的程序员,十分优秀!