HttpClientBuilderExtensions.ConfigurePrimaryHttpMessageHandler 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Action<HttpMessageHandler,IServiceProvider>)
添加一个委托,该委托将为已命名的 HttpClient 配置主要 HttpMessageHandler。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Action<System::Net::Http::HttpMessageHandler ^, IServiceProvider ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<System.Net.Http.HttpMessageHandler,IServiceProvider> configureHandler);
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Action<System.Net.Http.HttpMessageHandler, IServiceProvider> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Action(Of HttpMessageHandler, IServiceProvider)) As IHttpClientBuilder
参数
- builder
- IHttpClientBuilder
- configureHandler
- Action<HttpMessageHandler,IServiceProvider>
一个委托,用于配置以前设置或默认的主 HttpMessageHandler。
返回
可用于配置客户端的 IHttpClientBuilder。
注解
IServiceProvider提供给 的参数configureHandler
将是对作用域内服务提供程序的引用,该提供程序共享正在构造的处理程序的生存期。
适用于
ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)
添加一个委托,该委托将为已命名的 HttpClient 配置主要 HttpMessageHandler。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<IServiceProvider ^, System::Net::Http::HttpMessageHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<IServiceProvider,System.Net.Http.HttpMessageHandler> configureHandler);
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<IServiceProvider, System.Net.Http.HttpMessageHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of IServiceProvider, HttpMessageHandler)) As IHttpClientBuilder
参数
- builder
- IHttpClientBuilder
- configureHandler
- Func<IServiceProvider,HttpMessageHandler>
用于创建 HttpMessageHandler 的委托。
返回
可用于配置客户端的 IHttpClientBuilder。
注解
委托 configureHandler
应在每次调用消息处理程序时返回消息处理程序的新实例。
IServiceProvider提供给 的参数configureHandler
将是对作用域内服务提供程序的引用,该提供程序共享正在构造的处理程序的生存期。
适用于
ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)
添加一个委托,该委托将为已命名的 HttpClient 配置主要 HttpMessageHandler。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::HttpMessageHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.HttpMessageHandler> configureHandler);
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.HttpMessageHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of HttpMessageHandler)) As IHttpClientBuilder
参数
- builder
- IHttpClientBuilder
- configureHandler
- Func<HttpMessageHandler>
用于创建 HttpMessageHandler 的委托。
返回
可用于配置客户端的 IHttpClientBuilder。
注解
委托 configureHandler
应在每次调用消息处理程序时返回消息处理程序的新实例。
适用于
ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)
从已命名的 HttpClient 的依赖关系注入容器中配置主要 HttpMessageHandler。
public:
generic <typename THandler>
where THandler : System::Net::Http::HttpMessageHandler[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler<THandler> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) where THandler : System.Net.Http.HttpMessageHandler;
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Handler :> System.Net.Http.HttpMessageHandler)
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler(Of THandler As HttpMessageHandler) (builder As IHttpClientBuilder) As IHttpClientBuilder
类型参数
- THandler
DelegatingHandler 的类型。 处理程序类型必须注册为暂时性服务。
参数
- builder
- IHttpClientBuilder
返回
可用于配置客户端的 IHttpClientBuilder。
注解
THandler
将从共享所构造处理程序生存期的作用域内服务提供程序解析。