HttpClientFactoryServiceCollectionExtensions.AddHttpClient 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
AddHttpClient(IServiceCollection)
將 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
參數
- services
- IServiceCollection
傳回
適用於
AddHttpClient(IServiceCollection, String)
將 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
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient(IServiceCollection, String, Action<IServiceProvider,HttpClient>)
將 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
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- configureClient
- Action<IServiceProvider,HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient(IServiceCollection, String, Action<HttpClient>)
將 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
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- configureClient
- Action<HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,IServiceProvider,TImplementation>)
將 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
具型別客戶端的實作類型。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- factory
- Func<HttpClient,IServiceProvider,TImplementation>
用來建立 TClient
實例的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<HttpClient>)
將 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>具現化。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- configureClient
- Action<HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)
將 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>具現化。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- configureClient
- Action<IServiceProvider,HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, String)
將 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, 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>具現化。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,TImplementation>)
將 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
具型別客戶端的實作類型。
參數
- services
- IServiceCollection
- factory
- Func<HttpClient,TImplementation>
用來建立 TClient
實例的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,IServiceProvider,TImplementation>)
將 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
具型別客戶端的實作類型。
參數
- services
- IServiceCollection
- factory
- Func<HttpClient,IServiceProvider,TImplementation>
用來建立 TClient
實例的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<HttpClient>)
將 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>具現化。
參數
- services
- IServiceCollection
- configureClient
- Action<HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection)
將 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>具現化。
參數
- services
- IServiceCollection
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,TImplementation>)
將 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
具型別客戶端的實作類型。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- factory
- Func<HttpClient,TImplementation>
用來建立 TClient
實例的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<IServiceProvider,HttpClient>)
將 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>具現化。
參數
- services
- IServiceCollection
- configureClient
- Action<IServiceProvider,HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient>(IServiceCollection, String, Action<HttpClient>)
將 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>。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- configureClient
- Action<HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)
將 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>。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
- configureClient
- Action<IServiceProvider,HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient>(IServiceCollection, String)
將 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>。
參數
- services
- IServiceCollection
- name
- String
要設定之 HttpClient 的邏輯名稱。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
使用 DefaultName 作為名稱來設定預設用戶端。
適用於
AddHttpClient<TClient>(IServiceCollection, Action<HttpClient>)
將 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>。
參數
- services
- IServiceCollection
- configureClient
- Action<HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient>(IServiceCollection, Action<IServiceProvider,HttpClient>)
將 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>。
參數
- services
- IServiceCollection
- configureClient
- Action<IServiceProvider,HttpClient>
用來設定 HttpClient的委派。
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。
適用於
AddHttpClient<TClient>(IServiceCollection)
將 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>。
參數
- services
- IServiceCollection
傳回
可用來設定用戶端的 IHttpClientBuilder。
備註
HttpClient 可以使用 CreateClient(String) 擷取套用所提供組態的實例,並提供相符的名稱。
使用適當 HttpClient 建構的 TClient
實例,可以藉由提供 TClient
作為服務類型,從 GetService(Type)(和相關方法)擷取。