, MVCRecaptcha, , , . , , . , , , :
, , RenderControl html :
var captchaControl = new RecaptchaControl { ... }
var htmlWriter = new HtmlTextWriter(new StringWriter());
captchaControl.RenderControl(htmlWriter);
return htmlWriter.InnerWriter.ToString();
, MVC:
class CaptchaValidatorAttribute : ActionFilterAttribute {...}
, :
var recaptchaResponse = captchaValidtor.Validate();
filterContext.ActionParameters["captchaValid"] = recaptchaResponse.IsValid;
, :
[CaptchaValidator]
[AcceptVerbs( HttpVerbs.Post )]
public ActionResult CreateComment( Int32 id, bool captchaValid )
{
if (!captchaValid)
{
ModelState.AddModelError("_FORM", "You did not type the verification word correctly. Please try again.");
}
}
, , ASP.Net MVC.