開始在本地調用HTTPS接口的時候,程序拋出”基礎連接已關閉“的錯誤。
后來在代碼中加上:
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
本地程序不報錯,接口可以成功返回數據(本地.net framwork 3.5)
結果放到服務器后, 程序又出現”不支持此安全協議的錯誤“。
然后下載安裝了:https://support.microsoft.com/zh-cn/help/3154519/support-for-tls-system-default-versions-included-in-the-net-framework 之后就可以調用成功了。