getrequeststream error

To everyone:

below is a partial code that i am doing for parsing an html. this works fine on the first access. but at the second round it is hanging on getrequeststream(highligted in red). if there is anyone of you who have encounted this, please advise me of the solution.

Thank you so much.
Arequest.ContentType = "application/x-www-form-urlencoded"

Arequest.ContentLength = postData.Length

Arequest.Method = "POST"

Arequest.AllowAutoRedirect =False

Arequest.Timeout = 100000

'adsasddf

'Dim sCookieContainer As CookieContainer

'Arequest.CookieContainer = New CookieContainer

'Dim requestStream As Stream = Arequest.GetRequestStream()

Dim requestStreamAs Stream

requestStream =Nothing

requestStream = Arequest.GetRequestStream()

Dim postBytesAsByte() = Encoding.ASCII.GetBytes(postData)

requestStream.Write(postBytes, 0, postBytes.Length)

requestStream.Close()

requestStream =Nothing

Aresponse =CType(Arequest.GetResponse(), HttpWebResponse)

[1914 byte] By [JohnsonRoad] at [2008-2-25]
# 1
try closing your response
Malar at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...
# 2
There's another bug: You might send a wrong Content-Length header. Never use the post data's string length. Use the size of postBytes (i.e. the number of bytes after encoding your post data).
I'd also avoid ASCIIEncoding. This will break immediately once you want to post Latin 1 or other non-ASCII characters. Use UTF-8 or ISO-8859-1.

// UTF-8
Encoding enc = Encoding.UTF8;


or

// ISO-8859-1
Encoding enc = Encoding.GetEncoding(28591);


J?rgJooss at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...

.NET Development

Site Classified