美文网首页
请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法。

请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法。

作者: IBM_LELE | 来源:发表于2018-10-16 11:37 被阅读0次

在创建请求地址的前面加了这句代码就可以了:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

private string LoadURLString(string url, Encoding ed, string GetPost)

        {

            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url);

            request1.Method = GetPost;

            request1.ContentType = "application/json";

            request1.Accept = "application/json";

            return new StreamReader(((HttpWebResponse)request1.GetResponse()).GetResponseStream(), ed).ReadToEnd();

        }

相关文章

网友评论

      本文标题:请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法。

      本文链接:https://www.haomeiwen.com/subject/poaczftx.html