繁体   English   中英

VB。 NET:请求被中止:无法在 WebClient 上创建 SSL/TLS 安全通道

[英]VB. NET: The request was aborted: Could not create SSL/TLS secure channel on WebClient

我创建了一个可以在我的桌面上完美运行的程序,但是当我在笔记本电脑上使用相同的程序时,它不起作用。 它在我的笔记本电脑上显示错误“错误:请求被中止:无法创建 SSL/TLS 安全通道”。 我检查了互联网设置,它们也和我的桌面一样。 代码如下。

    Sub CheckUsername(ByVal word As String)
            Dim WC As New WebClient
            WC.Headers.Add("user-agent", " Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0")
            Dim t As Byte() = WC.DownloadData("https://www.google.com/search?q=" & word) 'This is the line that creates the error'
            Dim headers As WebHeaderCollection = WC.ResponseHeaders
            WC.Dispose()

            If headers.Count = 7 Then
                'MsgBox("True")'
            Else
                'MsgBox("False")'
            End If
    End Sub

我也尝试在开始时添加这些行作为研究,但它没有修复错误。

            ServicePointManager.Expect100Continue = True
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
What frameowrk version ur using ? if 4.6 and above that add like this before call that WebClient.
 



ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM