HttpClientFactory.Create vs new HttpClient

后端 未结 4 1154
小鲜肉
小鲜肉 2020-12-02 12:20

I am curious what is the purpose of the HttpClientFactory class. There is no description of why it exists on MSDN (see link).

There are Create methods with more spec

4条回答
  •  不思量自难忘°
    2020-12-02 12:53

    As mentioned in

    https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net-core

    The

    default constructor for HttpClient

    has sockets exhaustion and DNS changes issues, which are addressed by IHttpClientFactory. It also provide extensions for adding resiliency to the application.

提交回复
热议问题