//HttpContext context.Request.EnableRewind(); //创建缓冲区存放Request.Body的内容,从而允许反复读取Request.Body的Stream using (var ms=new MemoryStream()) {
context.Request.Body.Position = 0; //请求到控制器之后 Position重置0 context.Request.Body.CopyTo(ms); context.Request.Body.Position = 0; using (var st = new StreamReader(ms)) { st.BaseStream.Position = 0; body = st.ReadToEnd().Replace(" ", ""); } }