asp.net-web-api - 尝试激活“AspNetCoreRateLimit.IpRateLimitMiddleware”时无法解析“AspNetCoreRateLimit.IProcessingStrategy”类型的服务
问题描述
我使用了 AspNetCoreRateLimit Version="4.0.1" 包,但出现以下异常: Unable to resolve service for type 'AspNetCoreRateLimit.IProcessingStrategy' while trying to activate 'AspNetCoreRateLimit.IpRateLimitMiddleware' 但是当我使用包 AspNetCoreRateLimit Version=" 3.2.2" 有效。虽然 Version="4.0.1" 是最新的稳定版本,但我无法使用它。如果我继续使用 Version="3.2.2",以后会出现什么样的错误?
解决方案
根据 AspNetCoreRateLimit 的作者,您必须在 Startup.cs 中添加以下代码行
services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();
似乎他们不再注册默认的 IProcessingStrategy 。见这里:https ://github.com/stefanprodan/AspNetCoreRateLimit/issues/236#issuecomment-883311511
推荐阅读
- kubernetes - Kubernetes:角色与集群角色
- kubernetes - Kubernetes 集群中 CPU 内核使用率高(84%)
- javascript - React JSX highcharts 不会更新
- javascript - 如何在 vue js 中从 byte base64 下载文件
- c# - 非泛型类型“ActionResult”不能与类型参数一起使用
- android - 为什么在 ANDROID 中设置单个阿拉伯字符时,阿拉伯字符表现为单独的字符?
- excel - VBA Query 逐步工作,但在运行时会跳过
- qt - 无法将 [未定义] 分配给 QUrl
- c# - Razor Page 的常用路由?
- html - 背景视差图像不会调整大小