It’s not impossible that you’re accessing several different methods from the same Web Service in your application. If so, and if you’re using the HttpClientFactory (and you should be), you have an opportunity to centralize some of your code.

In your Startup class, you should be calling the AddHttpClient method, which, despite its name, actually adds an HttpClientFactory to your application’s services collection. As part of that method, you can pass the AddHttpClient method a string and a lambda expression. In the lambda expression you can provide the code to configure the HttpClient objects created by the factory. When it comes time to create an HttpClient object, you can use the string you provided to get the configuration you specified.

#httpclients #asp.net core #application

How to Handle Multiple HttpClients in the Same ASP.NET Core Application
32.60 GEEK