Commit 6226ec89 authored by liudong1993's avatar liudong1993

调整读取参数

parent bd6dd6a1
...@@ -124,17 +124,16 @@ namespace Property.WebApi.Filter ...@@ -124,17 +124,16 @@ namespace Property.WebApi.Filter
var request = actionContext.HttpContext.Request; var request = actionContext.HttpContext.Request;
#region 如果参数是json实体对象,获取序列化后的数据 #region 如果参数是json实体对象,获取序列化后的数据
request.EnableBuffering();
request.EnableBuffering();//重置读取 string responseData = "";
request.Body.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(request.Body, encoding: Encoding.UTF8))
request.Body.Position = 0; {
Stream stream = request.Body; var body = reader.ReadToEndAsync();
Encoding encoding = Encoding.UTF8; // Do some processing with body…
// Reset the request body stream position so the next middleware can read it
responseData = body.Result;
byte[] buffer = new byte[request.ContentLength.Value]; request.Body.Position = 0;
stream.Read(buffer, 0, buffer.Length); }
string responseData = Encoding.UTF8.GetString(buffer);
if (!string.IsNullOrWhiteSpace(responseData)) 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