使用以下方法:
Current.Request.EnableRewind();
Stream reqStream = Current.Request.Body;
byte[] buffer = new byte[Current.Request.ContentLength.Value];
reqStream.Read(buffer, 0, buffer.Length);
inputString = Encoding.UTF8.GetString(buffer);
Current.Request.Body.Position = 0;
注意: 不能通过以下方法读取body,否则倒带功能将失效
Current.Request.EnableRewind();
Stream reqStream = Current.Request.Body;
using (StreamReader reader = new StreamReader(reqStream))
{
inputString = reader.ReadToEnd();
}
Current.Request.Body.Position = 0;