TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Raysefo
1.5k
284
150.3k
web api DelegatingHandler question?
Feb 5 2019 8:46 AM
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)
{
// 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;
}
}
Reply
Answers (
4
)
how can webapi make scrapped?
Call Oracle BI Publisher Report from C#?