I try to log all posted data in my WebApi when a exception is thrown. I have try this:
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Content == null)
return await base.SendAsync(request, cancellationToken);
var Body = await request.Content.ReadAsStringAsync();
request.Properties["body"] = Body;
return await base.SendAsync(request, cancellationToken);
}
And in my error log method i get the posted values in Properties["body"].
But when the users upload a image I get this when I try to get the files:
This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked.
at System.Web.HttpRequest.get_Files()
How can I store only posted data(text) in this property?
Request.Form?