Stream s = System.Web.HttpContext.Current.Request.InputStream;
//s.Seek(0, SeekOrigin.Begin);
//Stream s = context.Request.InputStream;
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
Stream s = HttpContext.Current.Request.InputStream;//从输入流获得json字符流
//还原数据流
byte[] b = new byte[s.Length];
s.Position = 0;
s.Read(b, 0, (int)s.Length);
string jsontext = Encoding.UTF8.GetString(b); //JSON字符串
我的加上了这个:s.Position = 0; 就好了。你试试,希望采纳!
Stream s = HttpContext.Current.Request.InputStream;//获得json 字符流
//还原数据流
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
string jsontext = Encoding.UTF8.GetString(b); //JSON字符串
我获取得string jsontext 是一串0\,也不知道怎么弄的。也是用的postman。