webrequest.getResponse() method hangs

  • Thread starter Thread starter prakash
  • Start date Start date
P

prakash

Dear ALL

I am write an application for pocketpc . I use visual studio 2003.

I want to get a response string of an ASP web request query

I try this function

Public Shared Function GetResponseStringA(ByVal RemoteURL As String)
As String

Dim StartTime As DateTime = DateTime.Now()
Dim DownloadContent As String
Dim objRequest As Net.WebRequest, objResponse As Net.WebResponse,
objStreamReceive As System.IO.Stream, objEncoding As
System.Text.Encoding, objStreamRead As System.IO.StreamReader

Try
DownloadContent = ""
objRequest = Net.WebRequest.Create(RemoteURL)

objResponse = objRequest.GetResponse
objStreamReceive = objResponse.GetResponseStream
objEncoding = System.Text.Encoding.GetEncoding("utf-8")
objStreamRead = New System.IO.StreamReader(objStreamReceive,
objEncoding)
DownloadContent = objStreamRead.ReadToEnd()

If Not objResponse Is Nothing Then
objResponse.Close()
End If

Return DownloadContent
Catch ex As Exception
msgbox(ex.message)
End Try

End Function
--------------------------------------------------------------

This function works finely for few times

After five or six times . It hangs on the line
objResponse = objRequest.GetResponse.

How to fix that problem
bye
Prakash
 
Dear
Rick Spiewak . It also not working rick . the hang continous rick.
Is There any problem in my machine???
 
When I have done this, I used HTTPWebRequest (which inherits from
WebRequest, and is designed for HTTP usage). Try that.
 
Back
Top