Can WebApiThrottle be configured to have different policies for different functions
mohi-othman opened this issue · comments
mohi-othman commented
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?
Stefan Prodan commented
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";
}
}
tlwang32 commented
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?