我正在使用asp.net v4.0并在webrequest之后创建一个代码。它失败地说“ System.Net.WebException:无法连接到远程服务器---> System.Net.Sockets.SocketException:尝试对不可达网络进行套接字操作”,并引用了IPv6地址。该代码在Windows Server 2012上失败,在2008 r2服务器上的确切代码工作正常。未在网络适配器上检查IPv6。
Dim webReq As HttpWebRequest =
HttpWebRequest.Create("https://www.google.com/")
Try`enter code here`
Dim strResp As String
Using webResp As WebResponse = webReq.GetResponse
Using myStrm As StreamReader = New
StreamReader(webResp.GetResponseStream())
strResp = myStrm.ReadToEnd()
myStrm.Close()
End Using
webResp.Close()
End Using
Catch ex As Exception
HttpContext.Current.Response.Write(ex.ToString)
End Try