Как получить сырое содержимое тела (raw body) post или put запроса в .net minimal api?

Как получить сырое содержимое тела (raw body) post или put запроса в .net minimal API?

Я пробовал так:

app.MapPut($"/{controllerName}", async ([FromBody] BasisTypeDto dto, IRepository repo, HttpRequest request, HttpContext context) => {

    BuilderMinimalApiActionResult<object>.MakeActionResult(Crud.Update(dto, repo, host, DefaultElasticIndex)); }
)
    .AddEndpointFilter(async (efiContext, next) => {

        var s = efiContext.HttpContext.Features.Get<IHttpBodyControlFeature>();

        s.AllowSynchronousIO = true;
        var reader = new StreamReader(efiContext.HttpContext.Request.Body);

        var rawMessage = reader.ReadToEnd();
        return await next(efiContext);
    })

Но в rawMessage получаю пустую строку, хотя efiContext.HttpContext.Request.ContentLength == 112


Ответы (0 шт):