C#C
C#2y ago
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?
A base type for HTTP message handlers.
Was this page helpful?