post 发送和接收的问题

liaoxiaohua1981 2008-03-10 04:42:34
post后, 接收页面 接收到的数据为空。
发送代码如下:

string postdata = @"<?xml version ='1.0'?><LTSC_command version='1.0'><command_name>provision</command_name><command_data_block><action_id>1</action_id><service_id>1008</service_id> <uid>100008888</uid><phone_number>85188888</phone_number><agent_name> OK820C-IACJ</agent_name><data_id>2688</data_id><area_code>1</area_code></command_data_block></LTSC_command>";

byte[] requestbytes = System.Text.Encoding.Default.GetBytes(postdata);
string url = "http://125.XX.XX.XXX/wapPost/Default2.aspx";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Timeout = 10000000; //设定超时值
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.ContentLength = requestbytes.Length;
Stream requeststream = req.GetRequestStream();
requeststream.Write(requestbytes, 0, requestbytes.Length);
requeststream.Close();


接收代码如下:
System.IO.StreamWriter swb = null;
string LogPath = Server.MapPath("log.txt");
swb = new System.IO.StreamWriter(@LogPath, true, System.Text.Encoding.Default);
swb.WriteLine("12345");
try
{
Stream resStream = Request.InputStream;
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default);
//Response.Write(sr.ReadToEnd());

// swb.Write(xmldoc.OuterXml);
swb.WriteLine(sr.ReadToEnd());
// swb.WriteLine("1234");
swb.close();

}
catch
{

}



...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kings2015 2008-03-12
  • 打赏
  • 举报
回复
不会 顶一下
liaoxiaohua1981 2008-03-10
  • 打赏
  • 举报
回复
不得哦!没人!!!!!

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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