This project is read-only.

Invalid Operation Exception: Http request context does not exist.

Dec 2, 2014 at 4:07 AM
Well, recaptcha is used twice on site (both in process of registration). First time it works perfect, but second i got exception above (When GetCaptchaVerificatoinHelper method is called).
Also: first time recaptcha is located in form (page) which is loaded synchronously, second time recaptcha is located in PartialView, which is updated via ajax. How to fix this? Also, it would be nice if anybody gave me a reasons this happening. Thanks in advance.

This is problem method:
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");