close

使用 WebClient 存取 https 網站時發生如下錯誤

基礎連接已關閉: 無法為 SSL/TLS 安全通道建立信任關係
The underlying connection was closed: Could not establish trust relationship for SSL/TLS secure channel

解決方式.
WebClient wc = new WebClient();
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 
string HtmlCode = wc.DownloadString("https://xxx.xxx.xxx");

arrow
arrow

    浩瀚宇宙超級無敵 發表在 痞客邦 留言(0) 人氣()