public void OnActionExecuting(ActionExecutingContext filterContext)
 {
     _additionalCacheKey = _apiKeyService.ValidateRequestByApiKey(_additionalCacheKey);
     if ((_additionalCacheKey != null) && (_additionalCacheKey != "AuthorizedApi"))
     {
         ErrorResult(filterContext, String.Format("UnauthorizedApi: {0}", _request.QueryString["ApiKey"] ?? _request.Headers["ApiKey"]));
     }
 }
        public void ApplyFilter(Action baseAction, Action <string> unauthorizedResponseAction, Func <WorkContext> workContext, bool protectAlways)
        {
            IApiKeyService apiKeyService = null;

            if (workContext().TryResolve <IApiKeyService>(out apiKeyService))
            {
                _additionalCacheKey = apiKeyService.ValidateRequestByApiKey(_additionalCacheKey, protectAlways);
                if ((_additionalCacheKey != null) && (_additionalCacheKey != "AuthorizedApi"))
                {
                    var result = "UnauthorizedApi";
                    unauthorizedResponseAction(result);
                }
                else
                {
                    baseAction();
                }
            }
            else
            {
                baseAction();
            }
        }