HTTPWebResponse just hangs!

  • Thread starter Thread starter John Blair
  • Start date Start date
J

John Blair

Hi,

I am trying to post data to a url as follows but i don't get any response -
can anyone see anything missing from my code. Note: I have verified the url
(surl) i am targetting does exist. Thanks.

Dim buffer() As Byte = Encoding.UTF8.GetBytes(sPostData)

Dim hwreq As HttpWebRequest = WebRequest.Create(sUrl)

hwreq.Method = "POST"

hwreq.ContentType = "application/x-www-form-urlencoded"

hwreq.ContentLength = buffer.Length

hwreq.CookieContainer = New CookieContainer

Dim hwres As HttpWebResponse = hwreq.GetResponse

!!!!!!Above line never returns!!!!!!
 
Fixed it - i needed to add the following code:

Dim reqstream As Stream = hwreq.GetRequestStream()

reqstream.Write(buffer, 0, buffer.Length)
 
Back
Top