コード例 #1
0
 public override void OnActionExecuting(HttpActionContext actionContext)
 {
     if (!ThrottleHelper.CheckThrottle(Name, Milliseconds))
     {
         actionContext.Response = actionContext.Request.CreateErrorResponse(
             HttpStatusCode.Conflict,
             String.Format("The {0} action may only be performed every {1} seconds.", Name, Milliseconds));
     }
 }
コード例 #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!ThrottleHelper.CheckThrottle(Name, Milliseconds))
            {
                filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;

                filterContext.Result = new ContentResult
                {
                    Content = String.Format("The {0} action may only be performed every {1} seconds.", Name, Milliseconds)
                };
                filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict;
            }
        }