C#中HTTP请求失败及问题处理方案记录
- 先上一段代码
string responseString = string.Empty;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;// 4.0环境下https请求设置,否则会报请求被中止: 未能创建 SSL/TLS 安全通道。
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tlsl;环境4.5以上的写法
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method =