| 万能框架完美解决:“请求被中止: 未能创建 SSL/TLS 安全通道”问题 我们先来看几个类似的问题
 
 关于Htttphelper访问https://wx.qq.com无响应的解决方式
 http://www.sufeinet.com/thread-16482-1-1.html
 
 
 请求被中止: 未能创建 SSL/TLS 安全通道。
 http://www.sufeinet.com/thread-17704-1-1.html
 
 
 大家通过文章可以看的出来这个问题其实通常只需要配置
 
 [C#] 纯文本查看 复制代码 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;就行了,但是每个系统环境不同,.net版本不同,SecurityProtocolType的选择项目也是不同的,在此
 
 
 我为大家提供一个属性专门解决这个问题。
 
 
 使用方法
 
 当你使用万能框架时,只需要简单的一行代码即可
 
 [C#] 纯文本查看 复制代码  //创建Httphelper对象
            HttpHelper http = new HttpHelper();
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "http://wx.qq.com",//URL     必需项    
                SecurityProtocol = SecurityProtocolType.Tls,//当出现“请求被中止: 未能创建 SSL/TLS 安全通道”时需要配置此属性
            };
            //请求的返回值对象
            HttpResult result = http.GetHtml(item);
            //获取请请求的Html
            string html = result.Html;
            //获取请求的Cookie
            string cookie = result.Cookie;
 提供几个常用的SecurityProtocolType选项
 
 
 SecurityProtocolType.Tls12
 
 
 
 [C#] 纯文本查看 复制代码 
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
 SecurityProtocolType是一个枚举值,大家只需要在写代码时选择一个即可。
 
 好了就这样吧。
 
 万能框架下载地址:http://httphelper.sufeinet.com/
 
 
 |