I desire to use a web api filter to be able to collect the following from the request and response:
The request url, The method ( i.e. Get, POST…), both the request and response header key value pairs.
I searched stackoverflow at the following link and there is a good example of using a filter to capture the content.
Need to log asp.net webapi 2 request and response body to a database
I changed the following code from the example in the link above:
var responseBody = await result.Content.ReadAsStringAsync();
To:
var responseBody = await result.Header…; // when I picked Header methods – they would not work with await
Do Have a suggestion?
HttpHeadersdoes not have async methods. This answer shows how to extract header values.