简体   繁体   中英

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

I created a program which work flawlessly on my desktop but when I use the same program on my laptop, it doesn't work. It presents the error "Error: The request was aborted: Could not create SSL/TLS secure channel" on my laptop. I have checked the internet settings and they're the same as my desktop too. The code is below.

    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

I have also tried to add these lines at the start as researched, but it didn't fix the error.

            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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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