HttpClientFactoryServiceCollectionExtensions.AddHttpClient 方法

定義

多載

AddHttpClient(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollectionAdds the IHttpClientFactory and related services to the IServiceCollection.

AddHttpClient(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient.

AddHttpClient(IServiceCollection, String, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient.

AddHttpClient<TClient,TImplementation>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

AddHttpClient<TClient,TImplementation>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

AddHttpClient<TClient>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的完整名稱。The client name will be set to the full name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

AddHttpClient<TClient>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

AddHttpClient(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollectionAdds the IHttpClientFactory and related services to the 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

參數

傳回

AddHttpClient(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named 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 的邏輯名稱。The logical name of the HttpClient to configure.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named 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 的邏輯名稱。The logical name of the HttpClient to configure.

configureClient
Action<IServiceProvider,HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

AddHttpClient(IServiceCollection, String, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named 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 的邏輯名稱。The logical name of the HttpClient to configure.

configureClient
Action<HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

AddHttpClient<TClient,TImplementation>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

TImplementation

具型別用戶端的實類型。The implementation type of the typed client. 指定的類型會由 ITypedHttpClientFactory<TClient> 具現化They type specified will be instantiated by the ITypedHttpClientFactory<TClient>

參數

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

TImplementation

具型別用戶端的實類型。The implementation type of the typed client. 指定的類型會由 ITypedHttpClientFactory<TClient> 具現化They type specified will be instantiated by the ITypedHttpClientFactory<TClient>

參數

configureClient
Action<IServiceProvider,HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

TImplementation

具型別用戶端的實類型。The implementation type of the typed client. 指定的類型會由 ITypedHttpClientFactory<TClient> 具現化They type specified will be instantiated by the ITypedHttpClientFactory<TClient>

參數

configureClient
Action<HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

AddHttpClient<TClient,TImplementation>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

TImplementation

具型別用戶端的實類型。The implementation type of the typed client. 指定的類型會由 ITypedHttpClientFactory<TClient> 具現化They type specified will be instantiated by the ITypedHttpClientFactory<TClient>

參數

name
String

所要設定 HttpClient 的邏輯名稱。The logical name of the HttpClient to configure.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

TImplementation

具型別用戶端的實類型。The implementation type of the typed client. 指定的類型會由 ITypedHttpClientFactory<TClient> 具現化They type specified will be instantiated by the ITypedHttpClientFactory<TClient>

參數

name
String

所要設定 HttpClient 的邏輯名稱。The logical name of the HttpClient to configure.

configureClient
Action<IServiceProvider,HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

TImplementation

具型別用戶端的實類型。The implementation type of the typed client. 指定的類型會由 ITypedHttpClientFactory<TClient> 具現化They type specified will be instantiated by the ITypedHttpClientFactory<TClient>

參數

name
String

所要設定 HttpClient 的邏輯名稱。The logical name of the HttpClient to configure.

configureClient
Action<HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

AddHttpClient<TClient>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的完整名稱。The client name will be set to the full name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

參數

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

參數

configureClient
Action<IServiceProvider,HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

參數

configureClient
Action<HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

AddHttpClient<TClient>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

參數

name
String

所要設定 HttpClient 的邏輯名稱。The logical name of the HttpClient to configure.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

參數

name
String

所要設定 HttpClient 的邏輯名稱。The logical name of the HttpClient to configure.

configureClient
Action<IServiceProvider,HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named 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

具類型用戶端的類型。The type of the typed client. 指定的類型會以暫時性服務的形式在服務集合中註冊。They type specified will be registered in the service collection as a transient service. 如需撰寫具型別用戶端的詳細資訊,請參閱 ITypedHttpClientFactory<TClient>See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.

參數

name
String

所要設定 HttpClient 的邏輯名稱。The logical name of the HttpClient to configure.

configureClient
Action<HttpClient>

用來設定 HttpClient 的委派。A delegate that is used to configure an HttpClient.

傳回

可以用於設定用戶端的 IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

備註

您可以使用 CreateClient(String) 來抓取套用所提供設定的 @no__t 0 實例,並提供相符的名稱。 HttpClient instances that apply the provided configuration can be retrieved using CreateClient(String) and providing the matching name.

以適當的 HttpClient 所建立的 TClient 實例,可以透過提供 TClient 作為服務類型,從 @no__t 2 (和相關的方法)中取出。 TClient instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient as the service type.

使用 DefaultName 做為設定預設用戶端的名稱。Use DefaultName as the name to configure the default client.

適用於