我使用“ServicePointManager”来解决“请求被中止:无法创建 SSL/TLS 安全通道”的问题。
try
{
// ServicePointManager.Expect100Continue = true;
// ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//
// or this
//
// ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
var client = new WebClient();
var str = client.DownloadString(url);
textBox1.Text = str;
}catch (Exception ex){
MessageBox.Show(ex.Message);
}
但我的项目冻结/挂起。有人能帮我吗?