发送页面:
string strXML = " <root><a>test112</a></root> " ;
System.Net.WebClient wc = new System.Net.WebClient();
byte [] bs = System.Text.Encoding.Default.GetBytes(strXML);
byte [] bsReturn = wc.UploadData( " http://localhost/test/webform2.aspx " , bs);
string strReturn = System.Text.Encoding.Default.GetString(bsReturn);
Response.Write(strReturn);
Response.End();
接收页面:
protected void Page_Load( object sender, EventArgs e)
{
System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
try
{
dom.Load(Request.InputStream);
System.Xml.XmlNode node = dom.SelectSingleNode( " //a " );
if (node != null )
{
Response.Write( " nodeValue= " + node.InnerText);
}
}
catch
{
Response.Write( " 发生错误! " );
}
Response.End();
}
WebClient情况如下搜索: