请求被中止: 未能创建 SSL/TLS 安全通道

出现“请求被中止: 未能创建 SSL/TLS 安全通道。”的问题。

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

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

代码示例:

 System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serverURL);
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            strNewValue = "cmd=_notify-synch&tx=" + System.Web.HttpContext.Current.Request.QueryString["tx"] + "&at=" + PayPalParameter.BusinessToken;

猜你喜欢

转载自www.cnblogs.com/kekelele/p/8933442.html