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)