Skip to content

Read request body multiple times #40635

Closed
@HakamFostok

Description

@HakamFostok

I am aware of the limitation that the body request can be read only a once.

here is a blog post which allows me to read it twice

The problem is this approach allows to read the body BEFORE ASP.NET Core read it

I need to read the body again AFTER ASP.NET Core read it (for Serilog)

// here is program.cs file .NET 6
app.UseSerilogRequestLogging(options =>
    options.EnrichDiagnosticContext = (diagnosticContext, httpContext) =>
    {
        // I want to read the body here from httpContext
    }
);

Can this be done? if not do you have any plan to create new API that allow the user to do that if he opt-in for it?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions