Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
interface System.​Net.​Http.​IHttpClientFactory
Assembly: Microsoft.Extensions.Http
A factory abstraction for a component that can create <see cref="T:System.Net.Http.HttpClient" /> instances with custom configuration for a given logical name.
Remarks
A default <see cref="T:System.Net.Http.IHttpClientFactory" /> can be registered in an <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" />
by calling <see cref="M:Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient(Microsoft.Extensions.DependencyInjection.IServiceCollection)" /> .
The default <see cref="T:System.Net.Http.IHttpClientFactory" /> will be registered in the service collection as a singleton.
Methods
CreateClient​(string name)
Creates and configures an <see cref="T:System.Net.Http.HttpClient" /> instance using the configuration that corresponds
to the logical name specified by <paramref name="name" /> .
Returns A new <see cref="T:System.Net.Http.HttpClient" /> instance.
name
The logical name of the client to create.
Remarks
<para>
Each call to <see cref="M:System.Net.Http.IHttpClientFactory.CreateClient(System.String)" /> is guaranteed to return a new <see cref="T:System.Net.Http.HttpClient" />
instance. It is generally not necessary to dispose of the <see cref="T:System.Net.Http.HttpClient" /> as the
<see cref="T:System.Net.Http.IHttpClientFactory" /> tracks and disposes resources used by the <see cref="T:System.Net.Http.HttpClient" />.
</para> <para>
Callers are also free to mutate the returned <see cref="T:System.Net.Http.HttpClient" /> instance's public properties
as desired.
</para>