stefanprodan / WebApiThrottle

ASP.NET Web API rate limiter for IIS and Owin hosting
MIT License
1.28k stars 275 forks source link

Problem in applying different rates to different functions #131

Open tlwang32 opened 5 years ago

tlwang32 commented 5 years ago

I'd like to set the rate to 2/min for function #1 and to 10/min for the 2nd function following the example as the code below. The code is running fine, but the throttling is not working at all. I can get an unlimited number of "value" and "value1 and value2". Do I also need to change settings in webApiConfig.cs? Please help.

using System.Web.Http;
using WebApiThrottle;
namespace wepApiThrottle.Controllers
{
    [EnableThrottling(PerMinute = 2)]
    public class ValuesController : ApiController
    {
    // GET api/values
    [EnableThrottling(PerMinute = 2)]
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }

    // GET api/values/5
    [EnableThrottling(PerMinute = 10)]
    public string Get(int id)
    {
        return "value";
    }
}