Partager via


HttpClientBuilderExtensions.UseSocketsHttpHandler Method

Definition

Overloads

UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>)

Adds or updates SocketsHttpHandler as a primary handler for a named HttpClient and configures it using ISocketsHttpHandlerBuilder.

UseSocketsHttpHandler(IHttpClientBuilder, Action<SocketsHttpHandler,IServiceProvider>)

Adds or updates SocketsHttpHandler as a primary handler for a named HttpClient. If provided, also adds a delegate that will be used to configure the primary SocketsHttpHandler.

UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds or updates SocketsHttpHandler as a primary handler for a named HttpClient and configures it using ISocketsHttpHandlerBuilder.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ UseSocketsHttpHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Action<Microsoft::Extensions::DependencyInjection::ISocketsHttpHandlerBuilder ^> ^ configureBuilder);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder UseSocketsHttpHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<Microsoft.Extensions.DependencyInjection.ISocketsHttpHandlerBuilder> configureBuilder);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UseSocketsHttpHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Action<Microsoft.Extensions.DependencyInjection.ISocketsHttpHandlerBuilder> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function UseSocketsHttpHandler (builder As IHttpClientBuilder, configureBuilder As Action(Of ISocketsHttpHandlerBuilder)) As IHttpClientBuilder

Parameters

configureBuilder
Action<ISocketsHttpHandlerBuilder>

Delegate that is used to set up the configuration of the primary SocketsHttpHandler on ISocketsHttpHandlerBuilder that will later be applied on the primary handler during its creation.

Returns

An IHttpClientBuilder that can be used to configure the client.

Attributes

Remarks

If a primary handler was already set to be SocketsHttpHandler by previously calling, for example, ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>) or UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>), then the configuration set on ISocketsHttpHandlerBuilder will be applied to the existing instance. Otherwise, a new instance of SocketsHttpHandler will be created.

Applies to

UseSocketsHttpHandler(IHttpClientBuilder, Action<SocketsHttpHandler,IServiceProvider>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds or updates SocketsHttpHandler as a primary handler for a named HttpClient. If provided, also adds a delegate that will be used to configure the primary SocketsHttpHandler.

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder UseSocketsHttpHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<System.Net.Http.SocketsHttpHandler,IServiceProvider>? configureHandler = default);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UseSocketsHttpHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Action<System.Net.Http.SocketsHttpHandler, IServiceProvider> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function UseSocketsHttpHandler (builder As IHttpClientBuilder, Optional configureHandler As Action(Of SocketsHttpHandler, IServiceProvider) = Nothing) As IHttpClientBuilder

Parameters

configureHandler
Action<SocketsHttpHandler,IServiceProvider>

Optional delegate that is used to configure the primary SocketsHttpHandler.

Returns

An IHttpClientBuilder that can be used to configure the client.

Attributes

Remarks

If a primary handler was already set to be SocketsHttpHandler by previously calling, for example, ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>) or UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>), then the passed configureHandler delegate will be applied to the existing instance. Otherwise, a new instance of SocketsHttpHandler will be created.

Applies to