AspNet 报 Microsoft.AspNetCore.Connections.ConnectionAbortedException 异常

 

 如果在controller里面这样读取post上来的值

var ret = Request.BodyReader.ReadAsync().GetAwaiter().GetResult();

会在最终引发 Microsoft.AspNetCore.Connections.ConnectionAbortedException 异常

所以,改用这样读取:

 byte[] postContent = new byte[(int)Request.ContentLength];
            Request.Body.ReadAsync(postContent, 0, postContent.Length).Wait();

 

posted @ 2022-05-18 16:59  IWing  阅读(520)  评论(0编辑  收藏  举报