Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

c# - Client Side recaptcha verify throws 503 "service is not available"

The URL works if I run it in a browser, so key and response are correct. However when I run the code locally, it throws a 503 error. Any ideas?

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;
        }
    }
}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Solved. It turns out it was the web filter was the culprit. I moved my machine to a vlan without the web filter and the code works.

Thanks to everyone who took the time to read and answer my question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...