小编w4r*_*rcT的帖子

.NET 6 Logging middleware

We are trying to create a middleware that allows you to log in to an external service the body of an HTTP response.

We tried replacing it with a MemoryStream, but when we try to read it it turns out to be closed.

Could anyone help us?

Thanks in advance

Here is the code:

public class LogMiddleware 
{
    private readonly RequestDelegate _next;

    public LogMiddleware(RequestDelegate next) 
    {
        _next = next;
    }

    public async Task InvokeAsync(HttpContext context) 
    {
        var originBody = context.Response.Body; …
Run Code Online (Sandbox Code Playgroud)

.net-core asp.net-core .net-6.0

4
推荐指数
1
解决办法
6355
查看次数

标签 统计

.net-6.0 ×1

.net-core ×1

asp.net-core ×1