获取post的参数

            Stream stream = HttpContext.Request.Body;
            byte[] buffer = new byte[HttpContext.Request.ContentLength.Value];
            await stream.ReadAsync(buffer, 0, buffer.Length);
            string content = Encoding.UTF8.GetString(buffer);

知道body中的参数名字时

Request.Form["keyname"]

需要url解码时

System.Web.HttpUtility.UrlDecode(content,Encoding.UTF8);

 获取json字符串中的某一个值  

JObject obj = Newtonsoft.Json.Linq.JObject.Parse(ReText);
string freSpaceNum = obj["data"][0]["freSpaceNum"].ToString();
string resMag = ob["resMag"].ToString();

//JObject obj = JObject.Parse(result);
//JArray array = obj["data"] as JArray;                                                                                                                                            

posted @ 2021-01-06 15:00  青兰柳  阅读(333)  评论(0编辑  收藏  举报