I need to post the xml data which i need to get from the database and need to post this data to a url like(http://www.rentals.com/aspx) through asp.net.
views:
232answers:
2
+3
A:
you can write a function like this:
private string SendRequest(Uri UriObj , string data)
{
string _result;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(UriObj);
request.Method = "POST";
request.ContentType = "text/xml";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream streamResponse = response.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
_result = streamRead.ReadToEnd().Trim();
streamRead.Close();
streamResponse.Close();
response.Close();
return _result;
}
the string data can be xml like "<..>". on .aspx page to get the data, you need to use "Request.InputStream" and read stream into string, xml, etc...
Numenor
2009-05-14 11:57:17