stefanprodan / WebApiThrottle

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

How can I throttle perMonth? #70

Closed NanditaReshamwala closed 8 years ago

NanditaReshamwala commented 8 years ago

hi,

Thank you Stefan for your answer just before on other issue, I closed that issue. I have another question, we have to throttle PerMonth, Is it possible?

stefanprodan commented 8 years ago

You can't do that directly, as an workaround you can split your month limit in 4 and rate limit per week. This is one of the limitation of WebApiThrottle that I have addressed in the ASP.NET Core port. When you'll migrate your solution to .NET Core you can use AspNetCoreRateLimit where you can specify custom time ranges for the rate limits.

NanditaReshamwala commented 8 years ago

hi Stefan ,

Thank you for your prompt response. Is there anyway I can write handler when limit is reached or any kind of anyhandler I can write ?. My idea is that I update the policy run time (perWeek in my case) when the limit is about to reach.

stefanprodan commented 8 years ago

You can override the rate limit logic here ThrottlingHandler but updating the perWeek limit to solve the perMonth issue doesn't look good to me.

NanditaReshamwala commented 8 years ago

Thank you Stefan for guidelines.

NanditaReshamwala commented 8 years ago

hi Stefan,

I tried to override ThrottlingHandler method you suggested previously to override rate limit logic, but I think ThrottlingCore is not accessible outside of WebApiThrottle library.

Would you please help me how can I extend/override rate limit logic to support perMonth. We can not upgrade our project to.NET core at this stage.

Thank you.

NanditaReshamwala commented 8 years ago

hi Stefan,

My manager decided pricing perWeek, so I can use in built behaviour.

Thank you.