proudmonkey / ApiBoilerPlate

A simple yet organized project template for building ASP.NET Core APIs in .NET Core 3.1
MIT License
361 stars 77 forks source link

Runtime problem after updating AspNetCoreRateLimit to 4.0+ (with solution) #26

Closed improwise closed 3 years ago

improwise commented 3 years ago

If you run into problems like this after updating AspNetCoreRateLimit (or have it updated for you by another NuGet package):

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

This is the solution needed to get it working again:

        // See release notes for 4.0.0 https://github.com/stefanprodan/AspNetCoreRateLimit/releases
        services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();

In RegisterRequestRateLimiter class

proudmonkey commented 3 years ago

Thank you for sharing the solution ❤️