请求前加上
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();
}
作者:IBM_LELE
链接:https://www.jianshu.com/p/6ac55c3709d6
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
评论区