© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
41 replies
TJacken

Custom HttpMessageHandler to save http request and response in DB

Hi, is it good idea to overide SendAsync method from DelegateHandler and save request and response in DB?

https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpmessagehandler?view=net-8.0

I made custom HttpMessageHandler and inject repository in it, but when I call SaveChanges I got concurrency exception over db context when I run multiple http requests in parallel, everything is registered in DI correctly. So my question where is best place to save http request and http response in db?
HttpMessageHandler Class (System.Net.Http)
A base type for HTTP message handlers.
HttpMessageHandler Class (System.Net.Http)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Http 400 Bad Request Response [Answered]
C#CC# / help
4y ago
Save changes twice to db
C#CC# / help
4y ago
❔ HttpContext reading Request and Response body
C#CC# / help
3y ago
Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by...
C#CC# / help
3y ago