0

I have been troubleshooting this for hours. My code works when I use Google's public and private test keys. Is there something that I am missing?

What other steps can I take to test this code?

public static bool Validate(string encodedResponse)
{
    if (string.IsNullOrEmpty(encodedResponse)) return false;

    var client = new System.Net.WebClient();
    var secret = WebConfigurationManager.AppSettings["Google.ReCaptcha.Secret"];

    if (string.IsNullOrEmpty(secret)) return false;

    var googleReply = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, encodedResponse));

    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

    var reCaptcha = serializer.Deserialize<ReCaptcha>(googleReply);

    return reCaptcha.Success;
}

Code taken from paul at this link: Validating Recaptcha 2 (No CAPTCHA reCAPTCHA) in ASP.NET's server side

Community
  • 1
  • 1
  • Your missing the response from Google, makes it hard to figure out your problem – Mad Myche May 01 '17 at 23:19
  • The property values for `var reCaptcha`, particularly the the JSON native _error-codes_ should tell you what is going on. One thing may be that your host name that you are testing this on is not registered to be used with your ReCaptcha account (I've been a victim of that one) – Mad Myche May 01 '17 at 23:35

0 Answers0