HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost/test.asp");
myRequest.Method="POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
ASCIIEncoding encoder =
new ASCIIEncoding(); // Convert the string into a byte array. byte[] xmlBytes = encoder.GetBytes("xmlData="+xDoc.InnerXml);myRequest.ContentLength = xmlBytes.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(xmlBytes,0,xmlBytes.Length);
newStream.Close();
// Return the response.WebResponse myWebResponse = myRequest.GetResponse();
// Obtain a 'Stream' object associated with the response object.Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a higher level stream reader with the required encoding format.StreamReader readStream =
new StreamReader( ReceiveStream, encode );response = readStream.ReadToEnd();
readStream.Close(); readStream =
null;myWebResponse.Close();
Replies
Know the answer? Post it — somebody with the same question will find it here.