For logging purposes, I am trying to monitor the requests being made through a WebAPI. I have created and I am looking for a way to get back the body sent through in a request after the request has been fulfilled and responded to. I am trying to do this through using a ActionFilter but thus far have failed in reading the body from the request.
Can anybody give some advice how I may access this information?
For context I am trying to do this within this code:
public class LoggingActionFilter : ActionFilterAttribute { public override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken) { var test = actionExecutedContext.Request.Content.ReadAsStringAsync().Result; return base.OnActionExecutedAsync(actionExecutedContext, cancellationToken); } } I have tried reading back the Content on the actionExecutedContext variable in order to get back the body but have found this to return just blank so far.