HttpWebRequest - check for success?

S

Steve

Hi all,

I'm using the HttpWebRequest class to POST a form to a partner site.
Communication with the "Partner" site admin is shoddy at best and I'm having
a hard time determining if the POST is actually working. I'm not an HTTP
pro, should I expect to see some kind of response after I close the Stream
from GetResponseStream()? Any codes I can check for?

I have been watching the HasResponse property, but it's always false. Don't
know if that's normal or if that means I'm failing.

Here is the code:

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("https://<edited>.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.AllowAutoRedirect = true;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();


Any tips appreciated.

Thanks!
 
W

Winista

Call getresponse after you have written data into it. If you get 200 code
back, then it succeeded.
 

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