6.56Service Resolution Configuration

Created on Aug 17, 2026~1 min read

When configuring HttpClient globally, it is sometimes necessary to resolve dependent services before configuring the client. For example, the following example sets the request base address by resolving the configuration service:

cs
services.AddHttpClient(string.Empty, (serviceProvider, client) =>{    // Resolve the configuration service    var configuration = serviceProvider.GetRequiredService<IConfiguration>();    client.BaseAddress = new Uri(configuration["your-base-address"]);});