2014-10-08 37 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;