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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
使用 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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。
适用于
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。
注解
可以使用 CreateClient(String) 和提供匹配名称检索应用所提供的配置的 HttpClient 实例。
可以通过提供 TClient
作为服务类型,从 GetService(Type)(和相关方法)检索使用适当 HttpClient 构造的 TClient
实例。