Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript GoogleRecaptchaV3_Javascript_C#_Asp.net Mvc_Recaptcha - Fatal编程技术网

Javascript GoogleRecaptchaV3

Javascript GoogleRecaptchaV3,javascript,c#,asp.net-mvc,recaptcha,Javascript,C#,Asp.net Mvc,Recaptcha,我只想看看是否有人有一个Google recaptcha使用V3和ASP.NET的工作示例 我已经让它在本地工作,但我得到的回复似乎不包括recaptcha的评分 { "success": true, "challenge_ts": "2019-02-06T13:24:29Z", "hostname": "testkey.google.com" } 这就是我得到的结果,我想实现V3,在那里我可以得到评分。所有在线示例都使用PHP 我的代码: <div> @usi

我只想看看是否有人有一个Google recaptcha使用V3和ASP.NET的工作示例

我已经让它在本地工作,但我得到的回复似乎不包括recaptcha的评分

{
  "success": true,
  "challenge_ts": "2019-02-06T13:24:29Z",
  "hostname": "testkey.google.com"
}
这就是我得到的结果,我想实现V3,在那里我可以得到评分。所有在线示例都使用PHP

我的代码:

<div>
    @using (Html.BeginForm("FormSubmit", "Home", FormMethod.Post))
    {
        <div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></div>
        <input type="submit" value="Submit" />
    }
</div>
<script src='https://www.google.com/recaptcha/api.js' type="text/javascript"></script>
任何帮助都将不胜感激

[HttpPost]
public ActionResult FormSubmit()
{
    var response = Request["g-recaptcha-response"];
    string secretKey = "MY_Secret_Key";

    HttpClientHandler handler = new HttpClientHandler()
    {
        Proxy = WebProxy.GetDefaultProxy(),
        UseProxy = true
    };

    using (var client = new System.Net.Http.HttpClient(handler))
    {
        try
        {
            client.BaseAddress = new Uri("https://www.google.com/recaptcha/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            var result = client.GetStringAsync(string.Format("api/siteverify?secret={0}&response={1}", secretKey, response)).Result;

            var jsonReturned = JsonConvert.DeserializeObject(result);

        }
        catch (Exception exc)
        {
            throw exc;
        }
    }
}