WebApiThrottle限流框架——基于IP和客户端key的端点限流

如果同一个ip的客户端,在同一秒内,调用了2次api/values,其最后一次的调用将会被拒绝掉。

如果想接口通过唯一key去识别限制客户端,忽略客户端的ip地址限制,应该配置IpThrottling为false。

config.MessageHandlers.Add(new ThrottlingHandler()
{
    Policy = new ThrottlePolicy(perSecond: 1, perMinute: 30)
    {
        IpThrottling = true,
        ClientThrottling = true,
        EndpointThrottling = true
    },
    Repository = new CacheRepository()
});

猜你喜欢

转载自blog.csdn.net/u013938578/article/details/82947102