HttpClientFactoryServiceCollectionExtensions.AddHttpClient 方法

定義

多載

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 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

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 之間的繫結。 用戶端名稱將會設定為 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>

參數

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 做為服務類型,從(和相關的方法)中抓取。

適用於

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 做為服務類型,從(和相關的方法)中抓取。

適用於