stefanprodan / WebApiThrottle

ASP.NET Web API rate limiter for IIS and Owin hosting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can WebApiThrottle be configured to have different policies for different functions

mohi-othman opened this issue · comments

For instance my API has two functions A and B. Can we have A be limited to 1000 calls per day while B is limited to 2000?

Yes, check out the docs, you can apply different limits using the attributes

[EnableThrottling(PerSecond = 2)]
public class ValuesController : ApiController
{
    [EnableThrottling(PerDay = 1000)]
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }

    [EnableThrottling(PerDay = 2000)]
    public string Get(int id)
    {
        return "value";
    }
}

I cannot make the throttling part work using the above code. I can get the "value" and "value1, value2" for unlimited times. Is it required to change settings in WebApiConfig.cs?