3

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?

2
  • Why not use Request.Form? Commented Jun 29, 2015 at 17:05
  • 2
    There is no Request.Form in ApiController. Commented Jun 30, 2015 at 7:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.