HttpWebRequest 报错提示 “基础连接已关闭,发送时发生错误”

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_23502409/article/details/86610211

在使用HttpWebRequest请求API的时候总是报错,后来发现是需要设置传输协议。

在代码里面创建Request之前添加如下代码即可:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

猜你喜欢

转载自blog.csdn.net/qq_23502409/article/details/86610211