/// <summary> /// Determines whether the captcha is valid, and write error message if need. /// </summary> /// <param name="controllerBase"> /// The specified <see cref="ControllerBase" />. /// </param> /// <param name="errorText">The specified error message.</param> /// <param name="parameters">The specified parameters, if any.</param> /// <returns> /// <c>True</c> if the captcha is valid; otherwise, <c>false</c>. /// </returns> public static bool IsCaptchaValid(this ControllerBase controllerBase, string errorText, params ParameterModel[] parameters) { List <ParameterModel> list = CaptchaUtils.GetParameters(parameters); list.Add(new ParameterModel(DefaultCaptchaManager.ErrorAttribute, errorText)); return(CaptchaUtils.ValidateCaptcha(controllerBase, list)); }
/// <summary> /// Called by the ASP.NET MVC framework before the action method executes. /// </summary> /// <param name="filterContext">The filter context.</param> public override void OnActionExecuting(ActionExecutingContext filterContext) { CaptchaUtils.ValidateCaptcha(filterContext.Controller, new[] { new ParameterModel( DefaultCaptchaManager.ErrorAttribute, GetErrorMessage()) }); }