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

时间:2016-09-02 11:44:26   收藏:0   阅读:2347

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

技术分享

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

技术分享

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

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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!