public IActionResult SomeAction() { using (var mem = new MemoryStream()) using (var reader = new StreamReader(mem)) { Request.Body.Seek(0, SeekOrigin.Begin); Request.Body.CopyTo(mem); mem.Seek(0, SeekOrigin.Begin); var body = reader.ReadToEnd(); // Do something } using (var mem = new MemoryStream()) using (var reader = new StreamReader(mem)) { Request.Body.Seek(0, SeekOrigin.Begin); Request.Body.CopyTo(mem); mem.Seek(0, SeekOrigin.Begin); var body = reader.ReadToEnd(); // Do something } // More code return View(); }
参考