I have a situation where I'm running Umbraco 15 inside a larger .net core 9 web frontend app and it appears that when I make a POST request to the site, Umbraco is doing something to the request body and leaving the request in such a state that my app can't read the body content. The error message I get is something along these lines (note, this message is coming from within the Yarp ReverseProxy code):
Sent 0 request content bytes, but Content-Length promised 27
I narrowed down this issue to be related to Umbraco, as when I remove Umbraco entirely from the site, the body content can be read.
Is it possible that Umbraco is hijacking the request and reading the content before my app has a chance to read the stream? Or could there be something else going on that's disrupting the request content from being able to be read?
I found a workaround for now, but would like to understand what's going on that's causing this. The workaround is to add middleware which allows the content stream to be 'rewound' for reading again (from StackOverflow):
public class EnableRequestBodyBufferingMiddleware
{
private readonly RequestDelegate _next;
public EnableRequestBodyBufferingMiddleware(RequestDelegate next) =>
_next = next;
public async Task InvokeAsync(HttpContext context)
{
context.Request.EnableBuffering();
await _next(context);
}
}
Post Body Content Already Read
I have a situation where I'm running Umbraco 15 inside a larger .net core 9 web frontend app and it appears that when I make a POST request to the site, Umbraco is doing something to the request body and leaving the request in such a state that my app can't read the body content. The error message I get is something along these lines (note, this message is coming from within the Yarp ReverseProxy code):
I narrowed down this issue to be related to Umbraco, as when I remove Umbraco entirely from the site, the body content can be read.
Is it possible that Umbraco is hijacking the request and reading the content before my app has a chance to read the stream? Or could there be something else going on that's disrupting the request content from being able to be read?
I found a workaround for now, but would like to understand what's going on that's causing this. The workaround is to add middleware which allows the content stream to be 'rewound' for reading again (from StackOverflow):
is working on a reply...