日期:2014-05-16  浏览次数:20965 次

接收xml多了一个问号

string text = this.tbUser.Text;
            string str = this.mtbPsw.Text;
            string s = "username=" + HttpUtility.UrlEncode(text) + "&pwd=" + HttpUtility.UrlEncode(str);
            byte[] bytes = Encoding.UTF8.GetBytes(s);
            WebClient client = new WebClient();
            client.Encoding = Encoding.GetEncoding("utf-8");
            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            client.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
            byte[] buffer2 = null;
            try
            {
                buffer2 = client.UploadData("http://localhost:4137/User_Login.ashx", "POST", bytes);
            }
            catch (Exception)
            {
                MessageBox.Show("服务器未响应");
                return;
            }
            string xml = Encoding.UTF8.GetString(buffer2);

接收到xml的时候多了个问号


但是在post的页面是没有的。

这里的代码我家了个头是
report="<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+DataToXml.CDataToXml(table);
------解决方案--------------------
...Replace("<NewDataSet>","")
...Replace("</NewDataSet>","")

或自己用XmlDocument创建