0
那麼,recaptcha在現場使用兩次(兩者都在註冊過程中)。第一次它完美,但第二次我得到上面的異常(當GetCaptchaVerificatoinHelper方法被調用時)。 另外:第一次recaptcha位於同步加載的表單(page)中,第二次recaptcha位於PartialView中,通過ajax進行更新。如何解決這個問題?此外,如果有人給我一個這樣的原因,這將是很好的。提前致謝。Recaptcha - 無效操作例外:Http請求上下文不存在
這是問題的方法:
public Task<ActionResult> SendSmsAgain(CaptchaStubViewModel viewmodel)
{
viewmodel.NotificationMessage = null;
return Task<ActionResult>.Factory.StartNew(() =>
{
if (!HttpContext.Request.IsAjaxRequest())
return null;
var val = WebConfigurationManager.AppSettings["recaptchaPrivateKey"];
RecaptchaVerificationHelper helper = this.GetRecaptchaVerificationHelper(val);
viewmodel.CaptchaValue = helper.Response;
if (string.IsNullOrEmpty(helper.Response))
{ ModelState.AddModelError("CaptchaValue", "You should insert Captcha value to get an SMS");}...}
更新
改寫了沒有Ajax驗證邏輯,但這並不仍能正常工作。
Btw:重定向後使用第二個驗證碼。有誰能夠幫助我?我仍然得到同樣的錯誤。
Ajax與此錯誤無關,據我瞭解。 – Ryan 2014-12-03 03:23:09