WebApi 限制接口访问频率
1、使用Nuget,对WebAPI项目添加WebApiThrottle的引用 2、进行注册,一般是在WebApiConfig的Register方法里添加,代码如下: config.Filters.Add(new CustomThrottlingFilter() { Policy = new ThrottlePolicy() { //ip配置区域 IpThrottling = true, ClientThrottling = true, //端点限制策略配置会从EnableThrottling特性中获取。 EndpointThrottling = true } }); 其中CustomThrottlingFilter是自己重写的ThrottlingFilter,也可以直接用默认配置。我自定义的CustomThrottlingFilter如下: public class CustomThrottlingFilter : ThrottlingFilter { /// <summary> /// Sets the indentity. /// </summary> /// <param name="request">The request.</param> /// <returns>RequestIdentity.</returns> protected override