Created
October 28, 2014 00:16
-
-
Save pparadis/9b9613403e8f5564dce3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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