ASP.NET POST方式提交数据
2012-08-07 17:08
549 查看
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } else { if (Request["cmd"].Equals("1")) { //post解析地址 if (lon.Value.Trim().Length > 0 && lat.Value.Trim().Length > 0) { getaddress(lon.Value.Trim(), lat.Value.Trim()); } } } } private void getPostAddr(string lon, string lat) { string url = "http://www.ciensharp.com/api/addreq"; string postData = "postStr={" + string.Format("lon:{0},lat:{1},version:1.0.2", lon, lat) + "}&type=geocode"; Encoding encoding = Encoding.UTF8; byte[] data = encoding.GetBytes(postData); //准备请求 HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = data.Length; Stream stream = myRequest.GetRequestStream(); //发送数据 stream.Write(data, 0, data.Length); stream.Close(); //获取数据 HttpWebResponse res = (HttpWebResponse)myRequest.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8); string backstr = sr.ReadToEnd(); Response.Write(backstr); sr.Close(); res.Close(); }
相关文章推荐
- asp.net JS+form表单Post和Get方式提交数据
- 在ASP.NET中获取Get方式和Post方式提交的数据
- ASP.NET POST方式提交数据
- ASP.NET POST方式提交数据
- ASP.NET POST方式提交数据!
- asp.net 数据提交中的GET,POST, PUT,DELETE,四种方式
- asp.net Post Get提交数据转Model实例
- ASP.NET数据提交POST和GET【小说一下】
- Asp.net的post提交方式
- ASP.NET知识总结(2.对比Get和Post提交方式)
- ASP.NET Post方式提交
- ASP.NET MVC中get 和post方法传递数据的方式
- asp.net中用来进行Post和Get方式提交表单的方法
- ASP.NET 最全的POST提交数据和接收数据
- ASP.NET中POST提交数据并跳转页面
- 在ASP.NET中获取参数POST和GET方式提交的参数
- ASP.NET GET 方式提交数据!
- ASP.NET以Post方式向网页发送数据
- 在ASP.NET中获取参数POST和GET方式提交的参数
- 在ASP.NET中获取参数POST和GET方式提交的参数