You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really enjoy using this library. However, I've encountered an issue with registering custom RequestLoggingOptions for multiple HttpClients using HttpClientBuilderExtensions.LogRequestResponse in an ASP.NET Core environment on .NET 6.
Despite specifying different options, all HttpClients seem to use the first configured options.
Steps to Reproduce:
Using the ASP.NET Core sample app, if I create an additional service/interface MyOtherService / IMyOtherService and register it as follows, both clients use the same configuration options:
Each HttpClient should use its specified LogRequestResponse options.
Actual Behavior:
Both HttpClients use the configuration options specified for the first HttpClient.
Potential Cause:
I believe this issue stems from how LogRequestResponse handles HttpMessageHandler resolution, only registering one service factory instance.
Suggested Solution:
I've propose a change in the method to ensure AddHttpMessageHandler fetches named options and creates a new instance directly, detailed below. However, this may lead to the creation of a handler instance on every request. I've adjusted it to use keyed services for .NET 8+ environments that should mitigate this issue.
I really enjoy using this library. However, I've encountered an issue with registering custom RequestLoggingOptions for multiple HttpClients using HttpClientBuilderExtensions.LogRequestResponse in an ASP.NET Core environment on .NET 6.
Despite specifying different options, all HttpClients seem to use the first configured options.
Steps to Reproduce:
Using the ASP.NET Core sample app, if I create an additional service/interface MyOtherService / IMyOtherService and register it as follows, both clients use the same configuration options:
Expected Behavior:
Each HttpClient should use its specified LogRequestResponse options.
Actual Behavior:
Both HttpClients use the configuration options specified for the first HttpClient.
Potential Cause:
I believe this issue stems from how LogRequestResponse handles HttpMessageHandler resolution, only registering one service factory instance.
Suggested Solution:
I've propose a change in the method to ensure AddHttpMessageHandler fetches named options and creates a new instance directly, detailed below. However, this may lead to the creation of a handler instance on every request. I've adjusted it to use keyed services for .NET 8+ environments that should mitigate this issue.
Environment Details:
ASP.NET Core on .NET 6
Pull Request:
I will attach a new pull request shortly
Would appreciate any feedback on this issue and the proposed solution. Thanks for all of your great work.
The text was updated successfully, but these errors were encountered: