c# - Log request in ASP.NET Web Api -


i try log posted data in webapi when exception thrown. 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 error log method posted values in properties["body"].

but when users upload image when try files:

this method or property not supported after httprequest.getbufferlessinputstream has been invoked.
@ system.web.httprequest.get_files()

how can store posted data(text) in property?


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -