HttpWebRequest - check for success?

  • Thread starter Thread starter Steve
  • Start date Start date
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!
 
Call getresponse after you have written data into it. If you get 200 code
back, then it succeeded.
 
Back
Top