C# reCaptcha总是返回false

C# reCaptcha总是返回false,c#,asp.net-web-api,single-page-application,recaptcha,C#,Asp.net Web Api,Single Page Application,Recaptcha,可能是一个重复的问题。我有一个SPA和一个正在本地主机上运行的reCaptcha,它给了我一个错误:“false\nCorrect captcha sol”。下面显示了我使用的源代码。它以前使用相同的密钥(私有和公共)工作。我能做些什么改变或检查来让它工作呢?谢谢 var httpClient = new HttpClient(); var PK = ConfigurationManager.AppSettings["recaptchaKey"];//pr

可能是一个重复的问题。我有一个SPA和一个正在本地主机上运行的reCaptcha,它给了我一个错误:“false\nCorrect captcha sol”。下面显示了我使用的源代码。它以前使用相同的密钥(私有和公共)工作。我能做些什么改变或检查来让它工作呢?谢谢

            var httpClient = new HttpClient();
        var PK = ConfigurationManager.AppSettings["recaptchaKey"];//private key
        var userIP = ((HttpContextBase)this.Request.Properties["MS_HttpContext"]).Request.UserHostAddress;
        var uri = "http://www.google.com/recaptcha/api/verify";

        var postData = new List<KeyValuePair<string, string>>();
        postData.Add(new KeyValuePair<string, string>("privatekey", PK));
        postData.Add(new KeyValuePair<string, string>("remoteip", userIP));
        postData.Add(new KeyValuePair<string, string>("challenge", data.Challenge));
        postData.Add(new KeyValuePair<string, string>("response", data.Response));

        HttpContent content = new FormUrlEncodedContent(postData);

        string responseFromServer = await httpClient.PostAsync(uri, content)
                .ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode())
                .ContinueWith((readTask) => readTask.Result.Content.ReadAsStringAsync().Result);

        if (responseFromServer.StartsWith("true"))
        {
            return Contact(data);
        }
var-httpClient=new-httpClient();
var PK=ConfigurationManager.AppSettings[“recaptchaKey”]//私钥
var userIP=((HttpContextBase)this.Request.Properties[“MS_HttpContext”]).Request.UserHostAddress;
var uri=”http://www.google.com/recaptcha/api/verify";
var postData=新列表();
添加(新的KeyValuePair(“privatekey”,PK));
添加(新的KeyValuePair(“remoteip”,userIP));
添加(新的KeyValuePair(“challenge”,data.challenge));
添加(新的KeyValuePair(“response”,data.response));
HttpContent=新的FormUrlEncodedContent(postData);
string responseFromServer=等待httpClient.PostAsync(uri,内容)
.ContinueWith((postTask)=>postTask.Result.EnsureAccessStatusCode())
.ContinueWith((readTask)=>readTask.Result.Content.ReadAsStringAsync().Result);
if(responseFromServer.StartsWith(“true”))
{
返回联系人(数据);
}

在您发布到错误URL的文档之后 它的siteverify,而不是最终只验证。

我以前更改过提到的url,但只得到了以下错误:“{\n\”成功\“:错误,\n\”错误代码\“:[\n\”无效输入响应\“,\n\”缺少输入机密\“\n]\n}”您没有在POST上传递正确的字段正确的字段是:secret response remoteip(此字段是可选的)请看一下我寄给你的文件。