WebRequest works on two machines, but not on a third.

C

clockemail

I am using a web request in VB.Net to screen scrape a page on Server
X. The code works on my machine and another server when making the
call to Server X. However, if I use the code on Server X itself, the
following error is returned.

The underlying connection was closed: Unable to connect to the remote
server. at System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at
System.Net.HttpWebRequest.GetResponse()

The relevant code is as follows, in which url represents the address
of the web page from which the information is being read.

Dim result As WebResponse = Nothing
Dim strHTML As String = String.Empty
Dim SR As StreamReader = Nothing
Dim Req As WebRequest = WebRequest.Create(url)
Req.Credentials = CredentialCache.DefaultCredentials
Req.Proxy = WebProxy.GetDefaultProxy()
result = Req.GetResponse()
Dim stReceive As Stream = result.GetResponseStream()
SR = New StreamReader(stReceive)
strHTML = SR.ReadToEnd()
If Not result Is Nothing Then
result.Close()
result = Nothing
End If
If Not SR Is Nothing Then
SR.Close()
SR = Nothing
End If

I would be extremely grateful to anyone who could inform me of the
cause of the problem. The only possible cause I have found in other
postings is the use of a proxy server on Server X (I am waiting to
hear if a proxy server is being used). I would be even more grateful
for a solution to the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top