HTTPWebResponse just hangs!

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!!!!!!
 
J

John Blair

Fixed it - i needed to add the following code:

Dim reqstream As Stream = hwreq.GetRequestStream()

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

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