C#使用HttpWebRequest 进行请求,提示 基础连接已经关闭: 发送时发生错误。

本人今天遇到的错误,C#使用HttpWebRequest 进行请求,提示 基础连接已经关闭: 发送时发生错误。

测试了很久,才发现,是安全协议问题,把安全协议加上就可以了

请求的地址安全协议可能也不一样,

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

posted @ 2016-09-02 11:02  Bensonhai  阅读(8522)  评论(1编辑  收藏  举报