您的位置:首页 > 理论基础 > 计算机网络

Web Server 使用WebClient 发送https请求 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

2015-04-22 15:43 232 查看
使用WebClient 发送https请求

使用WebClient发送请求时,并且是以https协议;

WebClient webClient = new WebClient();

string result = webClient.DownloadString(url);

error : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

只需一行代码:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };//获取或设置用于验证服务器证书的回调。[SSL]

每个问题都有解决之法,遇到问题不要怕,解决问题才是提升最快的。

--------------------------------送给每天和bug打交道的博友们
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: