System.Net.WebException - The operation has timed-out.

G

Guest

Hi,

I'm having trouble executing this code. The first time everything works
fine, but al subsequent executions fail with this error:
System.Net.WebException - The operation has timed-out.

Code:

Dim mywriter As StreamWriter
Dim sWriter As New StringWriter
Dim writer As New Xml.XmlTextWriter(sWriter)
Dim objRequest As HttpWebRequest
Dim xmlRead As XmlTextReader

objRequest = WebRequest.Create(strUrl)
objRequest.Method = "POST"
objRequest.AllowWriteStreamBuffering = True
'objRequest.ContentLength = strXml.Length
objRequest.ContentType = "text/xml"


Dim myCred As New NetworkCredential
objRequest.Credentials = myCred

mywriter = New StreamWriter(objRequest.GetRequestStream())
mywriter.Write(strXml)
mywriter.Flush()
mywriter.Close()

Dim objResponse As HttpWebResponse = objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
'strResult = sr.ReadToEnd
xmlRead = New XmlTextReader(sr)

writer = Nothing
sWriter = Nothing
objRequest = Nothing
xmlRead = Nothing

The error occurs on this line:
sr = New StreamReader(objResponse.GetResponseStream())

Any ideas on what could be causing this and how I can solve it?

Thanks in advance,

Natasja
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top