語言

HttpClientFactoryServiceCollectionExtensions.AddHttpClient 方法

定義

多載

名稱 Description
AddHttpClient(IServiceCollection)

新增 及 IHttpClientFactory 相關服務至 IServiceCollection。

AddHttpClient(IServiceCollection, String)

將 及相關服務加入 IHttpClientFactory , IServiceCollection 並配置一個命名 HttpClient的 。

AddHttpClient(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

將 及相關服務加入 IHttpClientFactory , IServiceCollection 並配置一個命名 HttpClient的 。

AddHttpClient(IServiceCollection, String, Action<HttpClient>)

將 及相關服務加入 IHttpClientFactory , IServiceCollection 並配置一個命名 HttpClient的 。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,IServiceProvider,TImplementation>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,TImplementation>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,IServiceProvider,TImplementation>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,TImplementation>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<IServiceProvider,HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

AddHttpClient<TClient>(IServiceCollection, String, Action<HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient>(IServiceCollection, String)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

AddHttpClient<TClient>(IServiceCollection, Action<HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

AddHttpClient<TClient>(IServiceCollection, Action<IServiceProvider,HttpClient>)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

AddHttpClient<TClient>(IServiceCollection)

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

AddHttpClient(IServiceCollection)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

新增 及 IHttpClientFactory 相關服務至 IServiceCollection。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddHttpClient(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddHttpClient (services As IServiceCollection) As IServiceCollection

參數

傳回

IServiceCollection。

適用於

AddHttpClient(IServiceCollection, String)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 及相關服務加入 IHttpClientFactory , IServiceCollection 並配置一個命名 HttpClient的 。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name);
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpClient (services As IServiceCollection, name As String) As IHttpClientBuilder

參數

name
String

要配置的邏輯名稱 HttpClient 。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 及相關服務加入 IHttpClientFactory , IServiceCollection 並配置一個命名 HttpClient的 。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Action<IServiceProvider ^, System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<IServiceProvider,System.Net.Http.HttpClient> configureClient);
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<IServiceProvider, System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpClient (services As IServiceCollection, name As String, configureClient As Action(Of IServiceProvider, HttpClient)) As IHttpClientBuilder

參數

name
String

要配置的邏輯名稱 HttpClient 。

configureClient
Action<IServiceProvider,HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient(IServiceCollection, String, Action<HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 及相關服務加入 IHttpClientFactory , IServiceCollection 並配置一個命名 HttpClient的 。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Action<System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<System.Net.Http.HttpClient> configureClient);
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpClient (services As IServiceCollection, name As String, configureClient As Action(Of HttpClient)) As IHttpClientBuilder

參數

name
String

要配置的邏輯名稱 HttpClient 。

configureClient
Action<HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,IServiceProvider,TImplementation>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Func<System::Net::Http::HttpClient ^, IServiceProvider ^, TImplementation> ^ factory);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Func<System.Net.Http.HttpClient,IServiceProvider,TImplementation> factory) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Func<System.Net.Http.HttpClient, IServiceProvider, #'Client> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, name As String, factory As Func(Of HttpClient, IServiceProvider, TImplementation)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。

參數

name
String

要配置的邏輯名稱 HttpClient 。

factory
Func<HttpClient,IServiceProvider,TImplementation>

一個用來建立 的 TClient代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Action<System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<System.Net.Http.HttpClient> configureClient) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, name As String, configureClient As Action(Of HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。 指定的類型將由 實例化。ITypedHttpClientFactory<TClient>

參數

name
String

要配置的邏輯名稱 HttpClient 。

configureClient
Action<HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Action<IServiceProvider ^, System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<IServiceProvider,System.Net.Http.HttpClient> configureClient) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<IServiceProvider, System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, name As String, configureClient As Action(Of IServiceProvider, HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。 指定的類型將由 實例化。ITypedHttpClientFactory<TClient>

參數

name
String

要配置的邏輯名稱 HttpClient 。

configureClient
Action<IServiceProvider,HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, String)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, name As String) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。 指定的類型將由 實例化。ITypedHttpClientFactory<TClient>

參數

name
String

要配置的邏輯名稱 HttpClient 。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,TImplementation>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<System::Net::Http::HttpClient ^, TImplementation> ^ factory);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<System.Net.Http.HttpClient,TImplementation> factory) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<System.Net.Http.HttpClient, #'Client> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, factory As Func(Of HttpClient, TImplementation)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。

參數

factory
Func<HttpClient,TImplementation>

一個用來建立 的 TClient代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,IServiceProvider,TImplementation>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<System::Net::Http::HttpClient ^, IServiceProvider ^, TImplementation> ^ factory);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<System.Net.Http.HttpClient,IServiceProvider,TImplementation> factory) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<System.Net.Http.HttpClient, IServiceProvider, #'Client> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, factory As Func(Of HttpClient, IServiceProvider, TImplementation)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。

參數

factory
Func<HttpClient,IServiceProvider,TImplementation>

一個用來建立 的 TClient代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Action<System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<System.Net.Http.HttpClient> configureClient) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, configureClient As Action(Of HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。 指定的類型將由 實例化。ITypedHttpClientFactory<TClient>

參數

configureClient
Action<HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。 指定的類型將由 實例化。ITypedHttpClientFactory<TClient>

參數

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,TImplementation>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Func<System::Net::Http::HttpClient ^, TImplementation> ^ factory);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Func<System.Net.Http.HttpClient,TImplementation> factory) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Func<System.Net.Http.HttpClient, #'Client> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, name As String, factory As Func(Of HttpClient, TImplementation)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。

參數

name
String

要配置的邏輯名稱 HttpClient 。

factory
Func<HttpClient,TImplementation>

一個用來建立 的 TClient代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

TImplementation

適用於

AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<IServiceProvider,HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

public:
generic <typename TClient, typename TImplementation>
 where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Action<IServiceProvider ^, System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<IServiceProvider,System.Net.Http.HttpClient> configureClient) where TClient : class where TImplementation : class, TClient;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<IServiceProvider, System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class, TImplementation As Class) (services As IServiceCollection, configureClient As Action(Of IServiceProvider, HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

TImplementation

類型化客戶端的實作類型。 指定的類型將由 實例化。ITypedHttpClientFactory<TClient>

參數

configureClient
Action<IServiceProvider,HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient>(IServiceCollection, String, Action<HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient>
 where TClient : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Action<System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<System.Net.Http.HttpClient> configureClient) where TClient : class;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class) (services As IServiceCollection, name As String, configureClient As Action(Of HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

參數

name
String

要配置的邏輯名稱 HttpClient 。

configureClient
Action<HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient>
 where TClient : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name, Action<IServiceProvider ^, System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<IServiceProvider,System.Net.Http.HttpClient> configureClient) where TClient : class;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<IServiceProvider, System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class) (services As IServiceCollection, name As String, configureClient As Action(Of IServiceProvider, HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

參數

name
String

要配置的邏輯名稱 HttpClient 。

configureClient
Action<IServiceProvider,HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient>(IServiceCollection, String)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。

public:
generic <typename TClient>
 where TClient : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name) where TClient : class;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class) (services As IServiceCollection, name As String) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

參數

name
String

要配置的邏輯名稱 HttpClient 。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

用 DefaultName 名稱來設定預設客戶端。

適用於

AddHttpClient<TClient>(IServiceCollection, Action<HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

public:
generic <typename TClient>
 where TClient : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Action<System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<System.Net.Http.HttpClient> configureClient) where TClient : class;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class) (services As IServiceCollection, configureClient As Action(Of HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

參數

configureClient
Action<HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient>(IServiceCollection, Action<IServiceProvider,HttpClient>)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

public:
generic <typename TClient>
 where TClient : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Action<IServiceProvider ^, System::Net::Http::HttpClient ^> ^ configureClient);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<IServiceProvider,System.Net.Http.HttpClient> configureClient) where TClient : class;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<IServiceProvider, System.Net.Http.HttpClient> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class) (services As IServiceCollection, configureClient As Action(Of IServiceProvider, HttpClient)) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

參數

configureClient
Action<IServiceProvider,HttpClient>

一個用來配置 HttpClient的代理。

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於

AddHttpClient<TClient>(IServiceCollection)

來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs
來源:
HttpClientFactoryServiceCollectionExtensions.cs

將 IHttpClientFactory 及相關服務加入 ,IServiceCollection並在型別與命名 TClient之間配置綁定HttpClient。 客戶端名稱會被設定為型別名稱 TClient。

public:
generic <typename TClient>
 where TClient : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpClient(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpClient<TClient>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TClient : class;
static member AddHttpClient : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddHttpClient(Of TClient As Class) (services As IServiceCollection) As IHttpClientBuilder

類型參數

TClient

類型客戶的類型。 指定的類型會在服務集合中註冊為暫態服務。 請參閱 ITypedHttpClientFactory<TClient> 更多關於撰寫類型客戶端的細節。

參數

傳回

一個 IHttpClientBuilder 可以用來設定客戶端的

備註

HttpClient 套用所提供配置的實例可透過 CreateClient(String) 並提供匹配名稱來檢索。

TClient 使用適當 HttpClient 建構的實例可從(及相關方法)中取得 GetService(Type) ,提供 TClient 服務類型。

適用於