reCaptcha validation time out

夙愿已清 提交于 2019-12-12 03:14:23

问题


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.

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; 

}

回答1:


This could be due to firewall issues on the server being able to communicate to the google domain. If you have a firewall, it may not be letting through calls to google, especially if it is filtering by IP address. Google has a range of IP's that you need to open up.



来源:https://stackoverflow.com/questions/29117244/recaptcha-validation-time-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!