jeudi 4 juin 2015

C# ASP.NET reCAPTCHA 2.0 always returning false with no error codes

Background: This issue is with code that has been in place for a few months now, and had been working properly until a few days ago. No code changes have been made that would affect the reCAPTCHA, and I have tried generating new API keys and implementing them in my code with no luck (no error codes returned, just { success: "false" }).

Something interesting: When running this code locally (non-published through Visual Studio), reCAPTCHA works properly (i.e. returns either false or true appropriately and does not return any error codes) - I'm assuming because reCAPTCHA allows localhost traffic through without worrying about the API keys instead of checking against the domain.

Environment: Amazon Web Services server, all the necessary ports are open (both in the windows firewall and AWS control panel).

Question: Is there any server configurations or network issues that could cause reCAPTCHA to always return false, or is there something wrong with how I'm handling the code? Again, this was working properly for a few months and with over 300 requests.

string Response = Request.Form["g-recaptcha-response"];
bool Valid = false;
HttpWebRequest req  = (HttpWebRequest)WebRequest.Create(string.Format("http://ift.tt/1xSi4Qj}", System.Configuration.ConfigurationManager.ConnectionStrings["captchaKey"].ToString(), Response));

 try
 {
     using (WebResponse wResoponse = req.GetResponse())
     {
         using (StreamReader readStream = new StreamReader(wResoponse.GetResponseStream()))
         {
             string jsonResponse = readStream.ReadToEnd();

             JavaScriptSerializer js = new JavaScriptSerializer();
             MyObject data = js.Deserialize<MyObject>(jsonResponse);

             Valid = Convert.ToBoolean(data.success);
             }
         }
      return Valid;
  }
  catch (WebException ex)
  {
      throw ex;
  }

Here is the widget:

<div class="g-recaptcha" data-sitekey="6LeX4wcTAAAAAHXF2GRovVli1elAGwweKEjU_NEt"></div>

it's included inside the tag:

<form class="well form-horizontal" runat="server" id="contactformvalidation">




Aucun commentaire:

Enregistrer un commentaire