By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

The underlying connection was closed

P: n/a
Hi !
When i try to use webrequest class i get this error

The underlying connection was closed: An unexpected error occurred on a
receive.

I ma uisng vb.net and have no control on the server Can any one tell me how
i do fix that form my code?

Thanks
Suhail Kaleem
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Suhail Kaleem" <su**********@mailyoulike.com> schrieb:
When i try to use webrequest class i get this error

The underlying connection was closed: An unexpected error occurred on a
receive.

I ma uisng vb.net and have no control on the server Can any one tell me
how i do fix that form my code?


Does this only occur with a specific server only?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
Hi !
I get this problem on localhost (IIS) and also on web with my
host !

Thanks
Suhail kaleem
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
"Suhail Kaleem" <su**********@mailyoulike.com> schrieb:
When i try to use webrequest class i get this error

The underlying connection was closed: An unexpected error occurred on a
receive.

I ma uisng vb.net and have no control on the server Can any one tell me
how i do fix that form my code?


Does this only occur with a specific server only?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
Here is the code

Function get_web_data(ByVal url)
Dim html
' Debug.WriteLine(url)

'Create a WebRequest
Dim wrRequest As WebRequest
wrRequest = WebRequest.Create(url)

'Get the Response from the Request
Dim wrResponse As WebResponse = wrRequest.GetResponse()

'Read the Response into a stream and output the stream
Dim objStream As Stream = wrResponse.GetResponseStream()
Dim objStreamReader As StreamReader = New StreamReader(objStream)
Try
html += objStreamReader.ReadToEnd()
wrRequest.Abort()
objStream.Close()
objStreamReader.Close()

Catch ex As Exception
wrRequest.Abort()
objStream.Close()
objStreamReader.Close()
get_web_data = "Error: " & ex.Message.ToString
Exit Function
End Try

get_web_data = html
Debug.WriteLine(html)

End Function


"Suhail Kaleem" <su**********@mailyoulike.com> wrote in message
news:OL**************@TK2MSFTNGP15.phx.gbl...
Hi !
I get this problem on localhost (IIS) and also on web with my
host !

Thanks
Suhail kaleem
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
"Suhail Kaleem" <su**********@mailyoulike.com> schrieb:
When i try to use webrequest class i get this error

The underlying connection was closed: An unexpected error occurred on a
receive.

I ma uisng vb.net and have no control on the server Can any one tell me
how i do fix that form my code?


Does this only occur with a specific server only?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.