HttpWebRequest: 访问微信接口报 连接关闭错误: The underlying connection was closed。

参考:https://blog.csdn.net/wlanye/article/details/32137183

谢谢原文作者解决了我的问题。

我的是访问微信API接口一直报The underlying connection was closed。

试了各种方法:

方法1:ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3;

方法2.:request.KeepAlive = false;

方法3:ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

但是都没能解决问题:

最后这个  System.Net.ServicePointManager.Expect100Continue = false;加在方法第一行,

成功解决,真的是用了好几个小时,唉,还是要多学习啊,脑仁疼!

 

 

 

 

你可能感兴趣的:(c#)