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<HttpResponseMessage> SendAsync(
- HttpRequestMessage request, CancellationToken cancellationToken)
- {
-
- string requestBody = await request.Content.ReadAsStringAsync();
- Trace.WriteLine(requestBody);
-
-
- var result = await base.SendAsync(request, cancellationToken);
-
- if (result.Content != null)
- {
-
- var responseBody = await result.Content.ReadAsStringAsync();
- Trace.WriteLine(responseBody);
- }
-
- return result;
- }
- }