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。
備註
提供給 configureHandler
的IServiceProvider自變數將會是範圍服務提供者的參考,可共用所要建構之處理程式的存留期。
適用於
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
應該會在每次叫用訊息處理程式時傳回新的實例。
提供給 configureHandler
的IServiceProvider自變數將會是範圍服務提供者的參考,可共用所要建構之處理程式的存留期。
適用於
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
將會從共用所建構處理程式存留期的範圍服務提供者解析。