A
A User
Very strange - this code is copy and paste from the net and works on 2 of
my 3 development machines - but of course not the machine I need to run it
on.
I've seen similar posts, but no solutions that work for me. Is it a problem
with my proxy settings on this 1 machine? I have all the boxes unchecked
for LAN Settings. Net browsing is fine. Other machines are the same.
The error is:
An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The remote
name could not be resolved.
Code for form load:
'Create a new WebRequest object, which can only be done through the
static Create method of the WebRequest class
Dim wrGETURL As WebRequest
wrGETURL = WebRequest.Create("http:www.cnn.com")
'use whatever settings have been configured in Internet Explorer
wrGETURL.Proxy = WebProxy.GetDefaultProxy()
'use it to obtain a Stream object corresponding to the response to
your request.
Dim objStream As Stream
objStream = wrGETURL.GetResponse.GetResponseStream()
'After you have the response stream, you can treat it like any
other stream (such as from opening a text file) and read through its
contents line by line or even all at once. The loop below reads the stream
one line at a time until the ReadLine method returns Nothing, outputting
each line to the console.
Dim objReader As New StreamReader(objStream)
Dim i As Integer = 0
Me.TextBox1.Text = objReader.ReadToEnd
my 3 development machines - but of course not the machine I need to run it
on.
I've seen similar posts, but no solutions that work for me. Is it a problem
with my proxy settings on this 1 machine? I have all the boxes unchecked
for LAN Settings. Net browsing is fine. Other machines are the same.
The error is:
An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The remote
name could not be resolved.
Code for form load:
'Create a new WebRequest object, which can only be done through the
static Create method of the WebRequest class
Dim wrGETURL As WebRequest
wrGETURL = WebRequest.Create("http:www.cnn.com")
'use whatever settings have been configured in Internet Explorer
wrGETURL.Proxy = WebProxy.GetDefaultProxy()
'use it to obtain a Stream object corresponding to the response to
your request.
Dim objStream As Stream
objStream = wrGETURL.GetResponse.GetResponseStream()
'After you have the response stream, you can treat it like any
other stream (such as from opening a text file) and read through its
contents line by line or even all at once. The loop below reads the stream
one line at a time until the ReadLine method returns Nothing, outputting
each line to the console.
Dim objReader As New StreamReader(objStream)
Dim i As Integer = 0
Me.TextBox1.Text = objReader.ReadToEnd