How to read POST body data after HttpRequest.GetBufferlessInputStream is invoked

Viewed 125

I need to process POST request then post request back with the same body content. I have controller that handles POST request and binds data to model:

public HttpStatusCodeResult Post([FromBody]PayPalNotificationDto input) => _notificationHandler
        .Handle(HttpContext.Current.Request);

Also I have handler to manipulate with request data where I try to read body content like below:

    byte[] buffer = null;
    var param = request.GetBufferedInputStream().Read(buffer,0, request.ContentLength);
//  var param = request.BinaryRead(request.ContentLength); - also does not work

But reading body content throws ecxeption

this method is not supported after HttpRequest.GetBufferlessInputStream is invoked

Then I removed binding ([FromBody]PayPalNotificationDto input) from controller method as a result I was able to read content successfully.

My question is how I can read body content without removing model binding in controller moethod?

0 Answers
Related