在使用 System.Net.HttpWebRequest 和 System.Net.HttpWebResponse 时,如果无法通过 HTTPS 链接获取响应

原文链接:https://www.cnblogs.com/tangnie/p/3399229.html

在使用 System.Net.HttpWebRequestSystem.Net.HttpWebResponse 时,如果无法通过 HTTPS 链接获取响应,提示502 Bad Gateway

可能是由于多种原因导致的。以下是一些常见的问题和解决方法:

设置协议版本

在代码中显式设置支持的协议版本:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
posted @ 2025-05-27 17:38  yinghualeihenmei  阅读(30)  评论(0)    收藏  举报