Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to validate Google reCaptcha on my 1and1 hosted website.
But when I execute this function on Server, It takes too long and my page is timed out.
Can anyone point me out what is causing problem.

C#
private string VerifyRecaptcha(string secret, string responseCode)
{
    WebRequest request = WebRequest.Create("https://www.google.com/recaptcha/api/siteverify");
    request.Method = "POST";
    string postData = "secret=" + secret + "&response=" + responseCode;
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = byteArray.Length;
    Stream dataStream = request.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length);
    dataStream.Close();
    WebResponse response = request.GetResponse();
     dataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(dataStream);
    string responseFromServer = reader.ReadToEnd();
    reader.Close();
    dataStream.Close();
    response.Close();
    return responseFromServer;

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900