首页 > Web开发 > 详细

ASP.NET 处理get/post数据方式

时间:2014-02-24 10:34:08      阅读:381      评论:0      收藏:0      [点我收藏+]

1.GET方式

    NameValueCollection coding;
    coding = HttpUtility.ParseQueryString(Request.Url.Query, Encoding.GetEncoding("UTF-8"));
    Response.Write("coding[name]");
    Response.End();
    

说明:coding就是获取get传过来的键值对的变量。使用的时候就是 coding[‘key‘]得到value。当然也是key=value&key=value这种形式。

2.POST方式

bubuko.com,布布扣
    var inputStream = Request.InputStream;
    var strLen = Convert.ToInt32(inputStream.Length);
    var strArr = new byte[strLen];
    inputStream.Read(strArr, 0, strLen);
    var requestMes = Encoding.UTF8.GetString(strArr);
    var arr = requestMes.Split(=);
    inputStream.Close();
    inputStream.Dispose();
    Response.Write("alert(‘hello " + arr[1] + "!‘);");
    Response.End();
    
bubuko.com,布布扣

说明:requestMes变量用来得到post过来的信息,存的方式是key=value&key=value这种形式。但是requestMsg是字符串,不支持上面coding那种取值的方式。

ASP.NET 处理get/post数据方式

原文:http://www.cnblogs.com/JhoneLee/p/3562087.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!