6.55HttpClientOptions Extended Configuration (JSON Serialization)

Created on Aug 17, 2026~3 min read

The framework supports customizing options for HttpClient (such as JSON serialization behavior) through the IHttpClientBuilder.ConfigureOptions() extension method, and provides an overload that supports injectable service resolution. The example is as follows:

cs
// Configure the default clientservices.AddHttpClient(string.Empty)    .ConfigureOptions(options =>    // or use the overload: .ConfigureOptions((options, serviceProvider) =>    {        options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;    });// Configure a specific clientservices.AddHttpClient("github")    .ConfigureOptions(options =>    // or use the overload: .ConfigureOptions((options, serviceProvider) =>    {        options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;    });

With this configuration, you can customize the JSON serialization behavior for different HTTP client instances to meet the needs of specific remote requests.

HttpClientOptions contains the following properties:

  • Properties:
    • JsonSerializerOptions: JSON serialization configuration (of type JsonSerializerOptions).
    • JsonResponseWrapper: Specifies the JSON response deserialization wrapper (of type JsonResponseWrapper?).
    • UseJsonResponseWrapper: Whether to globally enable the JSON response deserialization wrapper (of type bool).
    • AccessTokenProvider: Access Token provider configuration (of type IHttpAccessTokenProvider?).
    • RequestEventHandler: HTTP event handler provider configuration (of type IHttpRequestEventHandler?).
    • QuotaLimits: API call quota limit configuration (of type Dictionary<string, HttpQuotaLimit>?).