Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve service for type 'AspNetCoreRateLimit.IProcessingStrategy' while attempting to activate 'AspNetCoreRateLimit.IpRateLimitMiddleware'

I have used the package AspNetCoreRateLimit Version="4.0.1" and I get the following exception: Unable to resolve service for type 'AspNetCoreRateLimit.IProcessingStrategy' while attempting to activate 'AspNetCoreRateLimit.IpRateLimitMiddleware' but when I use the package AspNetCoreRateLimit Version="3.2.2" it works. Although Version="4.0.1" is the latest stable version I am not being able to use it. What sort of bugs can I expect later if I keep on using Version="3.2.2"?

like image 764
Shihab Avatar asked Aug 23 '21 07:08

Shihab


Video Answer


1 Answers

According to the author of AspNetCoreRateLimit, you have to add following line of code in Startup.cs

services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();

It seems as they no longer have a default IProcessingStrategy registered. See here: https://github.com/stefanprodan/AspNetCoreRateLimit/issues/236#issuecomment-883311511

like image 83
thomasgalliker Avatar answered Nov 22 '22 10:11

thomasgalliker