Hello,
I wonder how to insert request/response JSON messages into database in delegatinghandler?
any help would be great.
- public class LogRequestAndResponseHandler : DelegatingHandler
- {
- protected override async Task
SendAsync( - HttpRequestMessage request, CancellationToken cancellationToken)
- {
- // log request body
- string requestBody = await request.Content.ReadAsStringAsync();
- Trace.WriteLine(requestBody);
- // let other handlers process the request
- var result = await base.SendAsync(request, cancellationToken);
- if (result.Content != null)
- {
- // once response body is ready, log it
- var responseBody = await result.Content.ReadAsStringAsync();
- Trace.WriteLine(responseBody);
- }
- return result;
- }
- }
RaysefoPosted Feb 11, 2019, 11:31 AM
Jefferson S. MottaPosted Feb 11, 2019, 9:58 AM
RaysefoPosted Feb 10, 2019, 3:39 AM
Jefferson S. MottaPosted Feb 9, 2019, 7:19 AM