How to write data to HttpWebRequest using stream / stream writer
Hi All,
I am using HttpWebRequest in my code.
My problem is that I want to post some data using HttpWebRequest, I have also written some code for this, see the part of code below,
HWReq.ContentLength = Buffer.Length;
Stream PostData = HWReq.GetRequestStream();
// HWReq is the HttpWebRequest object.
PostData.Write(Buffer, 0, Buffer.Length); // Buffer is the ByteArray.
PostData.Close();
during execution, I am not receiving any error but there is no effect of the above code.
I have also tried the following code, but it is also not working.
HWReq.ContentLength = cData.Length;
StreamWriter SW = new StreamWriter(HWReq.GetRequestStream());
// HWReq is the HttpWebRequest object.
SW.Write(cData, 0, cData.Length); // cData is the charector Array
SW.Close();
I am facing this proble since many days and still I have no solution,
Can any body help me please?
Any hint will also fine.
Thanks,
Kiran Suthar.
Answers
Know the answer? Post it. Somebody with the same question will find it here.