I am facing the Error "The underlying connection was closed: An unexpected error occurred on a send." in getting return data of google API.
It was fine locally but I had published and upload to server, I faced that Error. Help me please..
Best Regard...
WebClient webClient = new WebClient();
Stream stream = webClient.OpenRead("https://www.googleapis.com/oauth2/v1/userinfo?access_token=[Access_Token]);
string b;
/*I have not used any JSON parser because I do not want to use any extra dll/3rd party dll*/
using (StreamReader br = new StreamReader(stream))
{
b = br.ReadToEnd();
}
Your connection is connecting to a HTTPS endpoint, it may be possible that it requires TLS 1.2, which may not be the default TLS version of your client; this is a fix for older versions of .NET:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With