Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

RateLimiterOptions Class

Definition

Namespace:
Microsoft.AspNetCore.RateLimiting
Assembly:
Microsoft.AspNetCore.RateLimiting.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.RateLimiting v7.0.0-rc.2.22476.2
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
Source:
RateLimiterOptions.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Specifies options for the rate limiting middleware.

public sealed class RateLimiterOptions
type RateLimiterOptions = class
Public NotInheritable Class RateLimiterOptions
Inheritance
RateLimiterOptions

Constructors

Name Description
RateLimiterOptions()

Properties

Name Description
GlobalLimiter

Gets or sets the global PartitionedRateLimiter<TResource> that will be applied on all requests. The global limiter will be executed first, followed by the endpoint-specific limiter, if one exists.

OnRejected

Gets or sets a Func<T1,T2,TResult> that handles requests rejected by this middleware.

RejectionStatusCode

Gets or sets the default status code to set on the response when a request is rejected. Defaults to Status503ServiceUnavailable.

Methods

Name Description
AddPolicy<TPartitionKey,TPolicy>(String)

Adds a new rate limiting policy with the given policyName.

AddPolicy<TPartitionKey>(String, Func<HttpContext,RateLimitPartition<TPartitionKey>>)

Adds a new rate limiting policy with the given policyName

AddPolicy<TPartitionKey>(String, IRateLimiterPolicy<TPartitionKey>)

Adds a new rate limiting policy with the given policyName.

Extension Methods

Name Description
AddConcurrencyLimiter(RateLimiterOptions, String, Action<ConcurrencyLimiterOptions>)

Registers a new ConcurrencyLimiter with the given ConcurrencyLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

AddFixedWindowLimiter(RateLimiterOptions, String, Action<FixedWindowRateLimiterOptions>)

Registers a new FixedWindowRateLimiter with the given FixedWindowRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

AddSlidingWindowLimiter(RateLimiterOptions, String, Action<SlidingWindowRateLimiterOptions>)

Registers a new SlidingWindowRateLimiter with the given SlidingWindowRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

AddTokenBucketLimiter(RateLimiterOptions, String, Action<TokenBucketRateLimiterOptions>)

Registers a new TokenBucketRateLimiter with the given TokenBucketRateLimiterOptions to the application. The limiter can be added to an endpoint via RequireRateLimiting<TBuilder>(TBuilder, String), or via the EnableRateLimitingAttribute.

Applies to


Feedback

Was this page helpful?