2017-10-19 445 views
0

我在VB.net編碼的應用程序,它具有訪問web服務的這種方法,我有這個錯誤和搜索修復後,我仍然沒有運氣。VB。 NET:請求已中止:無法創建SSL/TLS安全通道

錯誤: 請求已中止:無法創建SSL/TLS安全通道。

'ServicePointManager.Expect100Continue = False 
    'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls 

    Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest) 

    Dim ErrMsg As String = String.Empty 

    Try 

     Dim response As WebResponse = request.GetResponse() 

     Using responseStream As Stream = response.GetResponseStream() 
      Dim reader As New StreamReader(responseStream, Encoding.UTF8) 

      Return reader.ReadToEnd() 
     End Using 
    Catch ex As WebException 

     ErrMsg = ex.Message.ToString 
     MsgBox(ErrMsg) 

     Dim errorResponse As WebResponse = ex.Response 
     Using responseStream As Stream = errorResponse.GetResponseStream() 
      Dim reader As New StreamReader(responseStream, Encoding.GetEncoding("utf-8")) 
      ' log errorText 
      Dim errorText As [String] = reader.ReadToEnd() 
     End Using 
     Throw 
    End Try 

這是我的代碼,我使用VS2015和Windows 10

所有幫助真的讚賞。 TIA

+0

也許web服務需要TLS 1.1/1.2? – MatSnow

+0

是墊我認爲問題就在這裏圈在此代碼:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls – wysiwyg327

+0

感謝墊,我想,解決方案,是的,它的工作原理,我創建了一個新項目,針對4.5框架,現在的挑戰是,我的項目瞄準4.0框架,當我將其更改爲4.5出現一堆錯誤。 – wysiwyg327

回答

相關問題