I am trying to read request body in ActionFilter but having some strange errors.
What I tried so far:
- Copying request body to memory stream
context.HttpContext.Request.Body.CopyTo(memoryStream)
Throws an error that only async operations are supported.
- Copying request body to memory stream async
context.HttpContext.Request.Body.CopyToAsync(memoryStream).Wait()
Copies 0 bytes
- Using BodyReader:
context.HttpContext.Request.BodyReader.AsStream(true).CopyToAsync(requestBody).Wait();
throws ArgumentOutOfRange exception 'Specified argument was out of the range of valid values. (Parameter 'start')'
I am using .net core 3.1