How does it work together with HttpClientFactory
See original GitHub issueHi, when I try to add this Handler like this:
services.AddSingleton<TracingHandler>(new TracingHandler(ServiceName));
services.AddHttpClient("MyHttpClient", ConfigureMyHttpClient)
.AddHttpMessageHandler<TracingHandler>();
I get error:
DelegatingHandler instances provided to HttpMessageHandlerBuilder must not be reused or cached
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Using HttpClientFactory in ASP.NET Core Applications
Not only that HttpClientFactory can create and manage new HttpClient instances but also, it works with underlying handlers.
Read more >Use the IHttpClientFactory - .NET
HttpClient is used for making HTTP requests and handling HTTP responses from web resources identified by a Uri. The HTTP protocol makes up...
Read more >Getting started with HttpClientFactory in C# and .NET 5
It provides a central place to name and configure our HttpClients . · Delegates handlers in HttpClient and implements Polly-based middleware to ...
Read more >Exploring the code behind IHttpClientFactory in depth
In this post I look in depth at the code behind the default implementation of IHttpClientFactory and see how it manages HttpClient handler ......
Read more >HTTP Requests Using IHttpClientFactory
It provides a single location to configure and interact with a particular httpclient. It works with dependency injection and can be injected ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@senj I believe you are getting this exception because you registered handler as singleton. So after first usage, inner handler stays set and that’s why you get exception. Try to change your registration to:
@dzejsien I am facing the same issue. .AddHttpMessageHandler(_ => TracingHandler.WithoutInnerHandler(“serviceName”)) did this solve the issue? Were you able to find other alternatives / best practices for this?