System.Net.WebException: 基礎連接已經關閉: 發送時發生錯誤。
目標積極拒絕。
在使用下面代碼時,發生上面的問題。
oHttp_Web_Req.GetResponse();
查找了很多,都不對,只有以下這種方案是最靠譜的。
解決辦法是這樣的:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12|SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.CheckCertificateRevocationList = false;
ServicePointManager.DefaultConnectionLimit = 512;
ServicePointManager.Expect100Continue = false;
HttpWebRequest oHttp_Web_Req = (HttpWebRequest)WebRequest.Create("https://XXXX.com");