I have added the recaptcha helper to a view I have created.
My controller looks like
[HttpPost]
public ActionResult Index(ContactModel model)
{
if (ReCaptcha.Validate(privateKey: ReCaptcha.PublicKey = System.Configuration.ConfigurationManager.AppSettings["RecaptchaKey"]))
{
}
}
Everytime the validation is failing, 2 questions
1. How do I pass the error back to view
2. Why is the result not been returned as valid when I know the key and the answer is correct?
Thank you
That code is not setting the private key correctly (or the public key for that matter). Set your private key in your controller, set the public key in your view.
In your controller:
In your view:
@ReCaptcha.GetHtml(publicKey:=System.Configuration.ConfigurationManager.AppSettings(“reCaptcha:publicKey”), theme:=”red”)
In web.config:
My example is in VB.NET, but you should be able to convert it easily.