469,270 Members | 1,398 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Underlying connection was closed, unable to connect

Jim
I have the following code:
Line 35: Dim sURL As String = "http://www.google.com"
Line 36: Dim data As Stream =
client.OpenRead(Server.UrlPath*Encode(sURL))
Line 37: Dim reader As New StreamReader(data)
Line 38: Results = reader.ReadToEnd()
I get an error on Line 36, Exception Details: System.Net.WebException:
The underlying connection was closed: Unable to connect to the remote
server.
The stack trace is below:
[WebException: The underlying connection was closed: Unable to connect
to the remote server.]
System.Net.HttpWebRequest.Chec*kFinalStatus()
System.Net.HttpWebRequest.EndG*etResponse(IAsyncRe sult asyncResult)

System.Net.HttpWebRequest.GetR*esponse()
System.Net.WebClient.OpenRead(*String address)
AtomzSearchPOC.Result.Page_Loa*d(Object sender, EventArgs e) in
c:\inetpub\wwwroot\GoogleTest\*Result.aspx.vb:36
System.Web.UI.Control.OnLoad(E*ventArgs e)
System.Web.UI.Control.LoadRecu*rsive()
System.Web.UI.Page.ProcessRequ*estMain()
Any help on resolving this issue would be appreciated

Nov 21 '05 #1
1 2625
Hi,

Try this instead.
Dim wc As New System.Net.WebClient

Dim sr As New System.IO.StreamReader(wc.OpenRead("http://news.google.com/"))

Dim strHtml As String

strHtml = sr.ReadToEnd

sr.Close()

wc.Dispose()
Ken
--------------------------
"Jim" <Ji***********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have the following code:
Line 35: Dim sURL As String = "http://www.google.com"
Line 36: Dim data As Stream =
client.OpenRead(Server.UrlPath*Encode(sURL))
Line 37: Dim reader As New StreamReader(data)
Line 38: Results = reader.ReadToEnd()
I get an error on Line 36, Exception Details: System.Net.WebException:
The underlying connection was closed: Unable to connect to the remote
server.
The stack trace is below:
[WebException: The underlying connection was closed: Unable to connect
to the remote server.]
System.Net.HttpWebRequest.Chec*kFinalStatus()
System.Net.HttpWebRequest.EndG*etResponse(IAsyncRe sult asyncResult)

System.Net.HttpWebRequest.GetR*esponse()
System.Net.WebClient.OpenRead(*String address)
AtomzSearchPOC.Result.Page_Loa*d(Object sender, EventArgs e) in
c:\inetpub\wwwroot\GoogleTest\*Result.aspx.vb:36
System.Web.UI.Control.OnLoad(E*ventArgs e)
System.Web.UI.Control.LoadRecu*rsive()
System.Web.UI.Page.ProcessRequ*estMain()
Any help on resolving this issue would be appreciated
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

26 posts views Thread by Rajeev Tipnis | last post: by
3 posts views Thread by MattM | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.