Web页面接受客户端POST数据,并且返回数据

本文介绍了如何使用C#在客户端向ASP.NET Web页面发送POST请求,并解析返回的XML数据。同时展示了如何在服务器端接收并处理这些POST数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

客户端post数据到asp.net页面

WebRequest wrPostURL = WebRequest.Create("http://edzh.com/Get.aspx");
    wrPostURL.Method = "POST";
    Stream postStream = wrPostURL.GetRequestStream();

//Dom为需要post的数据
    byte[] pPostBytes = System.Text.Encoding.UTF8.GetBytes(DOM.OuterXml);
    postStream.Write(pPostBytes,0,pPostBytes.Length);
    postStream.Flush();
    postStream.Close();

//responseStream为返回的xml数据

    Stream responseStream = wrPostURL.GetResponse().GetResponseStream();

    try
    {
     XmlDataDocument objXML = new XmlDataDocument();
     objXML.Load(responseStream);
     return objXML;
    }
    catch(XmlException ex)
    {
     throw new Exception(ex.ToSting())
    }

-------------------------------------------------

Get.aspx页面部分代码

//接受POST数据
    XmlDataDocument xmlDoc = new XmlDataDocument();
    try
    {

//Request.InputStream为post的数据,xml格式
     xmlDoc.Load(Request.InputStream);
    }
    catch/*(Exception ex)*/
    {
     //xml格式错误
     returnDesc += "Invalid XmlDocument";
    }

。。。。

。。。。。。。

posted on 2006-06-21 10:13 夜隼 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/yesun/archive/2006/06/21/431241.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值