2014-10-08 38 views
0

版本一把umbraco:6.2.1,轮廓:3.0.21 ...使用MVC模式的Recaptcha不工作的一把umbraco轮廓3.0.21

验证码字段不工作。表单提交时未验证验证码。

我已经尝试设置强制设置,无论在设置中和关闭...都没有效果。

验证适用于所有其他字段,但如果某个值在recaptcha字段中,表单仍然提交。

回答

1

尝试使用此代码:

  var recaptchaHelper = this.GetRecaptchaVerificationHelper(); 

      if (string.IsNullOrEmpty(recaptchaHelper.Response)) 
      { 
       ModelState.AddModelError("", "Captcha answer cannot be empty."); 

       return RedirectToCurrentUmbracoPage(); 
      } 

      var recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse(); 

      if (recaptchaResult != RecaptchaVerificationResult.Success) 
      { 
       ModelState.AddModelError("", "Incorrect captcha answer."); 
      } 

和这些引用:

使用Recaptcha.Web;

using Recaptcha.Web.Mvc;