Search code examples
asp.net-web-apiversionnuget-packagerate-limitingasp.net-core-5.0

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"?


Solution

  • 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