在用http發送一個DataSet時﹐為什么不能直接用byte[]發送呢?

sqfeiyu 2006-12-13 02:23:11
通過Http方式將Winform中的DataSet序列化后傳送到Web服務器中.
Winform中﹕
private void btnSend_Click(object sender, System.EventArgs e)
{
System.IO.MemoryStream strm=new System.IO.MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bfmt=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
bfmt.Serialize(strm,dstMain); System.Net.HttpWebRequest htp=(System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(tbxIP.Text);
htp.Method = "POST";
htp.ContentType = "application/x-www-form-urlencoded";
int i=0;
long L=strm.Length;
htp.ContentLength=L;
System.IO.Stream strm2=htp.GetRequestStream();
byte[] buf=strm.ToArray(); strm2.Write(buf,0,buf.Length);
System.Net.HttpWebResponse rst=(System.Net.HttpWebResponse)htp.GetResponse();
MessageBox.Show(rst.StatusDescription.ToString());
strm2.Close();
strm.Close();
}

ASP中﹕
private void Page_Load(object sender, System.EventArgs e)
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bfmt=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.Data.DataSet dst=(System.Data.DataSet)bfmt.Deserialize(Page.Request.InputStream);
dst.WriteXml(Server.MapPath("B.xml"));
}
...全文
138 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sqfeiyu 2006-12-19
  • 打赏
  • 举报
回复
???這么多天都沒有人來看看嗎﹖
sqfeiyu 2006-12-18
  • 打赏
  • 举报
回复
再頂一次﹐解決了的加分~~
sqfeiyu 2006-12-13
  • 打赏
  • 举报
回复
不是﹐上面是通以string方式發送的,然后用DataSet讀取數據﹐而我希望的是用二進制序列化將DataSet序列化后﹐直接以byte方式發出和接收﹐然后在Web服務器中再反序列化﹐得到DataSet
zhaochong12 2006-12-13
  • 打赏
  • 举报
回复
http://dage.5166.info/dg/89/aid21532_1/

是这样子的吗?..

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧