【问题标题】:Client Side recaptcha verify throws 503 "service is not available"客户端recaptcha验证抛出503“服务不可用”
【发布时间】:2021-04-17 13:29:25
【问题描述】:

如果我在浏览器中运行该 URL,则该 URL 有效,因此密钥和响应是正确的。但是,当我在本地运行代码时,它会引发 503 错误。有什么想法吗?

using System.Collections.Generic;
using System.Configuration;
using System.Net;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;


namespace ProjectM2.Shared
{
    public class ReCaptcha
    {
        public bool Success { get; set; }
        public List<string> ErrorCodes { get; set; }

        public static bool Validate(string encodedResponse)
        {
            if (string.IsNullOrEmpty(encodedResponse)) return false;

            var client = new System.Net.WebClient();

            var secret = ConfigurationManager.AppSettings["Google.ReCaptcha.Secret"];

            if (string.IsNullOrEmpty(secret)) return false;
            var googleReply = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, encodedResponse));
            var reCaptcha = JsonConvert.DeserializeObject<ReCaptcha>(googleReply);

            return reCaptcha.Success;
        }
    }
}

【问题讨论】:

标签: c# .net recaptcha


【解决方案1】:

解决了。事实证明,网络过滤器是罪魁祸首。我将我的机器移动到没有网络过滤器的 vlan 并且代码有效。

感谢所有花时间阅读并回答我的问题的人。

【讨论】:

    猜你喜欢
    • 2017-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-20
    • 2016-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多