Calling the System.Net.WebR esponse.GetResp onse method (see
code below) results in the following error:
System.Net.WebE xception: The underlying connection was
closed: An unexpected error occurred on a receive.
at(System.Net.H ttpWebRequest.C heckFinalStatus ())
at System.Net.Http WebRequest.EndG etResponse(IAsy ncResult
asyncResult)
at(System.Net.H ttpWebRequest.G etResponse())
The URL works ok in IE on the same PC.
Does anyone know what would cause this problem, what other
checks I could try or any other method to do the same
thing as System.Net.WebR esponse.GetResp onse?
Thank you in advance.
Private Function HasWebConnectio n() As Boolean
Dim bResult As Boolean
Try
bResult = True
Dim URI As New System.Uri("htt p://www.microsoft.c om")
Dim TestRequest As Net.WebRequest =
Net.WebRequest. Create(URI)
TestRequest.Tim eout = Threading.Timeo ut.Infinite
Dim TestResponse As Net.WebResponse =
TestRequest.Get Response
Catch ex As Exception
Console.WriteLi ne(ex.ToString)
bResult = False
End Try
Return bResult
End Function
code below) results in the following error:
System.Net.WebE xception: The underlying connection was
closed: An unexpected error occurred on a receive.
at(System.Net.H ttpWebRequest.C heckFinalStatus ())
at System.Net.Http WebRequest.EndG etResponse(IAsy ncResult
asyncResult)
at(System.Net.H ttpWebRequest.G etResponse())
The URL works ok in IE on the same PC.
Does anyone know what would cause this problem, what other
checks I could try or any other method to do the same
thing as System.Net.WebR esponse.GetResp onse?
Thank you in advance.
Private Function HasWebConnectio n() As Boolean
Dim bResult As Boolean
Try
bResult = True
Dim URI As New System.Uri("htt p://www.microsoft.c om")
Dim TestRequest As Net.WebRequest =
Net.WebRequest. Create(URI)
TestRequest.Tim eout = Threading.Timeo ut.Infinite
Dim TestResponse As Net.WebResponse =
TestRequest.Get Response
Catch ex As Exception
Console.WriteLi ne(ex.ToString)
bResult = False
End Try
Return bResult
End Function
Comment