stefanprodan / WebApiThrottle

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rate limit configuration via EnableThrottlingAttribute leads to exception

MelvilQ opened this issue · comments

I need to disable rate limits for two methods of my controller, so I switched from using ThrottlingHandler to ThrottlingFilter and configured the rate limits using EnableThrottlingAttribute and DisableThrottlingAttribute. Now, when a rate limit is reached, I don't get a 429 as expected. Instead, I get this exception:

System.InvalidOperationException: Unable to resolve type: System.Object, service name:
bei LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)
bei LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError)
bei LightInject.ServiceContainer.GetInstance(Type serviceType, Object[] arguments)
bei LightInject.ServiceFactoryExtensions.GetInstance[T1,T2,TService](IServiceFactory factory, T1 arg1, T2 arg2)
bei WebApiThrottle.ThrottlingFilter.OnActionExecuting(HttpActionContext actionContext)
bei System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()

I removed the QuotaExceededContent func property from ThrottlingFilter, and it works now. Apparently, LightInject gets in the way somehow.