Asp.Net Core 3.1 获取不到Post、Put请求的内容 System.NotSupportedException Specified method is not supported
2021-04-03 08:25
标签:意思 href host ima oca control state nal one 是这样的,我.net core 2.1的项目,读取、获取Post请求内容的一段代码,大概这样: 但这段代码 在 .net core 3.1.0 和 .net core 3.1.2(没错特地升级过) 都读不到、获取不到Post的内容: 报异常: StartUp Configure 这里改成这样: 搞定: 问题不大,不过不想让大家重复趟坑。 参考自: https://github.com/dotnet/aspnetcore/issues/15009 Asp.Net Core 3.1 获取不到Post、Put请求的内容 System.NotSupportedException Specified method is not supported 标签:意思 href host ima oca control state nal one 原文地址:https://www.cnblogs.com/xiaxiaolu/p/12543571.html问题
[HttpPost]
public async Task
curl --location --request POST 'http://localhost:5001/api/TestPostReader/test' --header 'Content-Type: application/json' --data-raw '{"name":"hei"}'
System.NotSupportedException: Specified method is not supported.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Seek(Int64 offset, SeekOrigin origin)
at Push.WebApi.Controllers.TestPostReaderController.Test() in D:\工作\39\solution-push\Push.WebApi\Controllers\TestPostReaderController.cs:line 21
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.
解决
app.Use((context, next) =>
{
context.Request.EnableBuffering();
return next();
});
//这个在后边
app.UseRouting();
文章标题:Asp.Net Core 3.1 获取不到Post、Put请求的内容 System.NotSupportedException Specified method is not supported
文章链接:http://soscw.com/index.php/essay/71732.html