簡體   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