Commit 6226ec89 authored by liudong1993's avatar liudong1993

调整读取参数

parent bd6dd6a1
......@@ -124,17 +124,16 @@ namespace Property.WebApi.Filter
var request = actionContext.HttpContext.Request;
#region 如果参数是json实体对象,获取序列化后的数据
request.EnableBuffering();//重置读取
request.Body.Seek(0, SeekOrigin.Begin);
request.Body.Position = 0;
Stream stream = request.Body;
Encoding encoding = Encoding.UTF8;
byte[] buffer = new byte[request.ContentLength.Value];
stream.Read(buffer, 0, buffer.Length);
string responseData = Encoding.UTF8.GetString(buffer);
request.EnableBuffering();
string responseData = "";
using (var reader = new StreamReader(request.Body, encoding: Encoding.UTF8))
{
var body = reader.ReadToEndAsync();
// Do some processing with body…
// Reset the request body stream position so the next middleware can read it
responseData = body.Result;
request.Body.Position = 0;
}
if (!string.IsNullOrWhiteSpace(responseData))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment