Skip to content

Instantly share code, notes, and snippets.

@pparadis
Created October 28, 2014 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pparadis/9b9613403e8f5564dce3 to your computer and use it in GitHub Desktop.
Save pparadis/9b9613403e8f5564dce3 to your computer and use it in GitHub Desktop.
[HttpPost]
public async Task<ActionResult> Form()
{
RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
if (String.IsNullOrEmpty(recaptchaHelper.Response))
{
ModelState.AddModelError("", "Le captcha ne peut être vide.");
return PartialView();
}
RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();
if (recaptchaResult != RecaptchaVerificationResult.Success)
{
ModelState.AddModelError("", "Réponse captcha invalide.");
return PartialView();
}
if (ModelState.IsValid)
{
return PartialView("_FormResult");
}
return PartialView();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment