M
Mike
I am posting data in a loop. Looping 25 times works. Looping 99 times
doesn't work. I have looked at the free memory and free memory is actually
higher when it fails than when it started. Why would posting data fail on
the 50th time of doing the same thing over and over?
Here is the post code:
Dim req As System.Net.HttpWebRequest
Dim bPostData() As Byte
Dim Stream1 As System.IO.Stream
Dim resp As System.Net.WebResponse
req = Utils.CreateWebRequest(VsURL)
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
' Encode the data
bPostData = System.Text.Encoding.UTF8.GetBytes(VsPost)
req.ContentLength = bPostData.Length
' Write encoded data into request stream
Stream1 = req.GetRequestStream()
Stream1.Write(bPostData, 0, bPostData.Length)
Stream1.Close()
resp = req.GetResponse()
Dim myStream As System.IO.Stream = resp.GetResponseStream()
Dim encode As System.text.Encoding =
System.Text.Encoding.GetEncoding("utf-8")
' Pipe the stream to a higher level stream reader with the required encoding
format.
Dim readStream As New System.IO.StreamReader(myStream, encode)
Dim strResponse As String = readStream.ReadToEnd()
' Release the resources of stream object.
readStream.Close()
' Close the response to free resources.
resp.Close()
doesn't work. I have looked at the free memory and free memory is actually
higher when it fails than when it started. Why would posting data fail on
the 50th time of doing the same thing over and over?
Here is the post code:
Dim req As System.Net.HttpWebRequest
Dim bPostData() As Byte
Dim Stream1 As System.IO.Stream
Dim resp As System.Net.WebResponse
req = Utils.CreateWebRequest(VsURL)
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
' Encode the data
bPostData = System.Text.Encoding.UTF8.GetBytes(VsPost)
req.ContentLength = bPostData.Length
' Write encoded data into request stream
Stream1 = req.GetRequestStream()
Stream1.Write(bPostData, 0, bPostData.Length)
Stream1.Close()
resp = req.GetResponse()
Dim myStream As System.IO.Stream = resp.GetResponseStream()
Dim encode As System.text.Encoding =
System.Text.Encoding.GetEncoding("utf-8")
' Pipe the stream to a higher level stream reader with the required encoding
format.
Dim readStream As New System.IO.StreamReader(myStream, encode)
Dim strResponse As String = readStream.ReadToEnd()
' Release the resources of stream object.
readStream.Close()
' Close the response to free resources.
resp.Close()