WebResponse

jamie_pattison

Well-known member
Joined
Sep 9, 2008
Messages
116
Programming Experience
Beginner
I have an unusual problem her. using a WebRequest and WebResponse object to get some data from an external server.

During testing, if i attempt to access the server and contents, my first attempt - runs fine. Second attempt do the same task and that runs fine too. Third attempt nothing happens.

I thought this may be because ive not released any resouces - so pretty much set everything to nothing. This didnt work. I then thought perhaps the server is noting that im attempting too many times in a short space of time, i then attempted to access after 1 minute or so and the same issue.

I have Try blocks to catch any exceptions and none are raised.

Would anyone know what and why this is happening or how to narrow down the issue?

Thanks
 
can you post your code please?
 
can you post your code please?

Thanks...As you can tell, MessageBox.Show(_WebRes.SOMEPROPERTY.ToString) displays twice and the third time it hangs.

The URL is passed in (CompleteUrl)

VB.NET:
        Try
            _WebReq = Nothing
            _WebRes = Nothing

            _WebReq = WebRequest.Create(CompleteUrl)
            _WebReq.AllowAutoRedirect = bAllowAutoRedirect
            _WebReq.Timeout = iTimeout

            _WebReq.Credentials = New NetworkCredential("user", "password")
            _WebRes = _WebReq.GetResponse

             MessageBox.Show(_WebRes.SOMEPROPERTY.ToString)

        Catch we As WebException
            MessageBox.Show(we.Message.ToString())
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString())
        End Try
 
thought this may be because ive not released any resouces - so pretty much set everything to nothing.
Setting everything to Nothing doesn't solve anything. You have to close/dispose the objects. WebRes.Close()
 
Back
Top