Exceptionless.Net icon indicating copy to clipboard operation
Exceptionless.Net copied to clipboard

POST JSON DATA IS NULL

Open maxwell60701 opened this issue 10 months ago • 3 comments

In my post http request,the json data is null,bad request 400,If I add code

app.Use(async (context, next) => { if (context.Request.Body.CanSeek) { context.Request.Body.Position = 0; } await next(); }); after app.UseExceptionless(); it worked,It should be the stream position is not reseted to 0 after reading

maxwell60701 avatar Mar 25 '25 02:03 maxwell60701

Thanks for reaching out! Our middleware should run last (if registered first) and should only read the post body if it's at position 0 or can be reset. One can also enable buffering: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httprequestrewindextensions.enablebuffering?view=aspnetcore-9.0

If you can provide a sample or update our sample via a pr that reproduces we would be more than happy to dig into this further. Also are you suggesting that we reset it to what ever position it was at before we read it? If you could provide a use case and update this issue / sample that would be a massive help.

niemyjski avatar Mar 28 '25 02:03 niemyjski

Please let me know if you have any questions

niemyjski avatar Mar 31 '25 13:03 niemyjski

Also, make sure you define app.UseExceptionless as soon as possible in your Configure method.

niemyjski avatar Apr 07 '25 12:04 niemyjski