HttpClientBuilderExtensions.UseSocketsHttpHandler Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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>)
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
- builder
- IHttpClientBuilder
The IHttpClientBuilder.
- 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>)
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
- builder
- IHttpClientBuilder
The IHttpClientBuilder.
- 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.