Partager via


HttpClientFactoryOptions.SuppressHandlerScope Property

Definition

Gets or sets a value that determines whether the IHttpClientFactory will create a dependency injection scope when building an HttpMessageHandler. If false (default), a scope will be created, otherwise a scope will not be created.

This option is provided for compatibility with existing applications. It is recommended to use the default setting for new applications.

public:
 property bool SuppressHandlerScope { bool get(); void set(bool value); };
public bool SuppressHandlerScope { get; set; }
member this.SuppressHandlerScope : bool with get, set
Public Property SuppressHandlerScope As Boolean

Property Value

Remarks

The IHttpClientFactory will (by default) create a dependency injection scope each time it creates an HttpMessageHandler. The created scope has the same lifetime as the message handler, and will be disposed when the message handler is disposed.

When operations that are part of HttpMessageHandlerBuilderActions are executed they will be provided with the scoped IServiceProvider via Services. This includes retrieving a message handler from dependency injection, such as one registered using AddHttpMessageHandler<THandler>(IHttpClientBuilder).

Applies to