6.49HttpClient Instance Configuration

Created on Aug 17, 2026~1 min read

The HTTP remote request service uses HttpClient internally to send requests. By configuring the HttpClient client, you can adjust the behavior of the framework when sending HTTP remote requests. You can configure client behavior in the following two ways:

Global Configuration

Configure clients for all requests or for a specific name in Startup.cs or Program.cs:

cs
// Enable for the default clientservices.AddHttpClient(string.Empty, client => {});// Enable for a specific clientservices.AddHttpClient("weixin", client => {});// If you need to resolve services, use the following overloadservices.AddHttpClient(string.Empty, (serviceProvider, client) => {});

Per-Request Configuration

Use SetHttpClientProvider to customize the client for a specific request:

cs
HttpRequestBuilder.Get("https://furion.net/")    .SetHttpClientProvider(() => (new HttpClient(new HttpClientHandler    {        // ...    }), client => client.Dispose()));