使用 Post 方法传递数据
来源:互联网 发布:ipadpro必备软件推荐 编辑:程序博客网 时间:2024/06/09 16:09
使用 Post 方法传递数据 --ASP.net
示例在paike.3g.cn/zdtu/TestRecPostData.aspx
以及CommonBg/Test/TestPostData.aspx
------------------------------------------------
---1,请求页面,即POST页面----
private string sendUrl = "http://paike.3g.cn/zdtu/TestRecPostData.aspx";
private string postdata = @"name=tuzuodong&data=英国暴风雪导致孕妇数量增加
PostData(postdata, sendUrl);
public void PostData(string postData,string recUrl)
{
UTF8Encoding code = new UTF8Encoding(); //这里采用UTF8编码方式
//string postData = "aa=iceapple.net&bb=yibin.net"; //这是要post的数据
byte[] data = code.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(recUrl);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded"; //这里的ContentType很重要!
request.ContentLength = data.Length;
using (Stream stream = request.GetRequestStream()) //获取数据流,该流是可写入的
{
stream.Write(data, 0, data.Length); //发送数据流
stream.Close();
}
}
-----2, 接收POST数据页面-----------------
string postData="";
string name="";
//name = Request.QueryString["name"] as string; //post方法不支持GET的接收方式,必须用Request.Form的方式
//postData = Request.QueryString["data"] as string; //post方法不支持GET的接收方式,必须用Request.Form的方式
if(Request.Form["name"]!=null)
{
name = Request.Form["name"].ToString();
}
if(Request.Form["data"]!=null)
{
postData = Request.Form["data"].ToString();
}
参考:http://www.cftea.com/c/2008/07/B0AUNSSUA1NQCVIF.asp
- 使用 Post 方法传递数据
- servlet之间的数据传递-使用POST方法
- ThinkPHP与Angular使用POST方法传递数据的问题
- AJAX的POST方法传递数据
- 表单post方法传递数据到后端
- 使用Apache接口post方式传递数据
- 在JQuery中可以使用get,post和ajax方法给服务器端传递数据
- HTML数据的传递方式:get方法 和 post 方法
- 使用get方法传递数据
- POST传递数据(VC)
- href传递post方法。
- php 分页显示数据 post参数传递问题解决方法
- Android通过POST方法传递数据给服务器
- php 分页显示数据 post参数传递问题解决方法
- mvc3 怎么传递非 模型 数据 给post方法
- 传递数据的两种方法GET和POST
- C#.Net前端数据post传递方法(mvc)
- Jfinal中使用post的数据传递方式
- jQuery学习笔记6 模糊查询过滤器
- 计算几何 作编程参考
- Access 模糊查询的小细节
- jquery的replace
- POJ 3415 Common Substrings(后缀数组+单调栈)
- 使用 Post 方法传递数据
- 内省、JavaBean、PropertyDescriptor类、Introspector类、BeanUtils工具包、注解、Rentention、Target、注解的基本属性和高级
- activity的四种启动模式
- Ubuntu中SVN客户端安装+使用
- matlab gui 生成独立可执行的程序
- 将数字上调至8的倍数
- mysql 字符集以及大小写规范
- 再次使用Kindeditor的经验
- Aborting commit: 'XXXXXXXX'remains in conflict错误