C#中,怎么接收以post字节流以xml格式传送的数据

解决方案 »

  1.   

    HttpContext.Current.Response.Clear();
            
            //Request.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            System.IO.Stream stream = Request.InputStream;
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            try
            {
                doc.Load(stream); //加载发送过来的Xml文档
            }
            catch
            {
                byte[] buffer = new byte[stream.Length];
                stream.Read(buffer, 0, buffer.Length);
                string strXML = System.Text.UnicodeEncoding.Default.GetString(buffer, 0, buffer.Length);
                doc.LoadXml(strXML);
            }
    代码:http://dcx1122happy.blog.163.com/blog/static/74982341200948111241646/