# Abp.AspNetCoreRateLimit
(opens new window) (opens new window) (opens new window) (opens new window) (opens new window)
An Abp module helps you control how often your service is used.
# Installation
Install the following NuGet packages. (see how (opens new window))
- EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit
- EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit.Client
- EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit.Ip
Add
DependsOn(typeof(AbpClientLimiterModule))
andDependsOn(typeof(AbpIpLimiterModule))
attribute to configure the module dependencies. (see how (opens new window))Extends IHostBuilder with Limiter configuration methods.
IHostBuilder.UseAspNetCoreRateLimitIp(); IHostBuilder.UseAspNetCoreRateLimitClient();
Register the middleware below within the
OnApplicationInitialization()
method ofAppModule.cs
"before" theUseRouting()
middleware
:app.UseIpRateLimiting(); app.UseClientRateLimiting();
Add the following code at
ConfigureServices()
methodcontext.Services.AddLimiterService<MemoryCacheRateLimitCounterStore>(service => { service.AddLimiterIpService<MemoryCacheIpPolicyStore>(); service.AddLimiterClientService<MemoryCacheClientPolicyStore>(); });
# Documentation
Rate limiting based on client IP
- Setup and configuration (opens new window)
- Defining rate limit rules (opens new window)
- Behavior (opens new window)
- Update rate limits at runtime (opens new window)
Rate limiting based on client ID
- Setup and configuration (opens new window)
- Defining rate limit rules (opens new window)
- Behavior (opens new window)
- Update rate limits at runtime (opens new window)
Advanced configuration
- Customize the quoata exceeded response (opens new window)
- IP / ClientId resolve contributors (opens new window)
- Use Redis as a distributed counter store (opens new window)
# Roadmap
- [ ] Unit test