services.AddHttpClient("MyClient").ConfigureHttpClient((services, client) => { client.BaseAddress = new Uri("https://example.com"); client.DefaultRequestHeaders.Add("User-Agent", "MyUserAgent"); });
services.AddHttpClient("MyClient").AddHttpMessageHandlerIn the above code examples, the "AddHttpClient" method is used to configure HttpClient and add middleware components. These examples are part of the Microsoft.Extensions.Http package library.();