HttpClientBuilderExtensions.AddHttpMessageHandler 方法

定义

重载

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

添加一个委托,该委托将用于为已命名的 HttpClient 创建附加消息处理程序。

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

添加一个委托,该委托将用于为已命名的 HttpClient 创建附加消息处理程序。

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

从已命名的 HttpClient 的依赖关系注入容器中添加附加消息处理程序。

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

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

添加一个委托,该委托将用于为已命名的 HttpClient 创建附加消息处理程序。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<IServiceProvider ^, System::Net::Http::DelegatingHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<IServiceProvider,System.Net.Http.DelegatingHandler> configureHandler);
static member AddHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<IServiceProvider, System.Net.Http.DelegatingHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of IServiceProvider, DelegatingHandler)) As IHttpClientBuilder

参数

configureHandler
Func<IServiceProvider,DelegatingHandler>

用于创建 DelegatingHandler 的委托。

返回

可用于配置客户端的 IHttpClientBuilder

注解

每次调用委托时,该 configureHandler 委托都应返回消息处理程序的新实例。

提供给 configureHandler 的参数IServiceProvider将是对共享所构造处理程序生存期的作用域服务提供程序的引用。

适用于

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

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

添加一个委托,该委托将用于为已命名的 HttpClient 创建附加消息处理程序。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::DelegatingHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.DelegatingHandler> configureHandler);
static member AddHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.DelegatingHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of DelegatingHandler)) As IHttpClientBuilder

参数

configureHandler
Func<DelegatingHandler>

用于创建 DelegatingHandler 的委托。

返回

可用于配置客户端的 IHttpClientBuilder

注解

每次调用委托时,该 configureHandler 委托都应返回消息处理程序的新实例。

适用于

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

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

从已命名的 HttpClient 的依赖关系注入容器中添加附加消息处理程序。

public:
generic <typename THandler>
 where THandler : System::Net::Http::DelegatingHandler[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpMessageHandler<THandler> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) where THandler : System.Net.Http.DelegatingHandler;
static member AddHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Handler :> System.Net.Http.DelegatingHandler)
<Extension()>
Public Function AddHttpMessageHandler(Of THandler As DelegatingHandler) (builder As IHttpClientBuilder) As IHttpClientBuilder

类型参数

THandler

DelegatingHandler 的类型。 处理程序类型必须注册为暂时性服务。

参数

返回

可用于配置客户端的 IHttpClientBuilder

注解

THandler将从共享所构造处理程序生存期的作用域服务提供程序解析 。

适用于