System.Net.WebException: The underlying connection was closed...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Crowther

    System.Net.WebException: The underlying connection was closed...

    On one PC the following test code results in an error on
    the GetResponse line while it works OK on another PC. The
    only difference that I am aware of is that the one that
    works is XP while the problem occurs on Windows 2000. I
    have tested that the Internet connection is OK through IE.
    Does anyone know what the problem could be? The error is:

    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())

    Private Function TestForWebConne ction() As Boolean
    Dim bResult As Boolean
    Try
    bResult = True
    Dim URI As New System.Uri
    ("http://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

Working...