9

I have ASP.NET Core 2.1 project which uses a class library built on .Net Core 2.1. In .Net Core 2.1 class library i need to make several REST class,for which i am using HttpClient class.

I want to leverage the benefits of HttpClientFactory for creating and using HttpClient instances.

How can i use HttpClientFactory in .Net Core 2.1 class library.

7
  • Are you certain that you actually need to use HttpClientFactory? If the class library you're using only creates a few, long-lived instances of HttpClient then you don't need to use HttpClientFactory. If you do need to use it, then you would pass it in as a DI parameter to some "service" class object instance instantiated in ASP.NET Core's own DI container. Commented Mar 8, 2019 at 7:26
  • Idea to use HttpClientFactory was to make use of the functionality available for Retry and Fault Handling. Commented Mar 8, 2019 at 8:33
  • The http instances used in class libraries are not long lived,and i need to make call to different rest endpoints often. Commented Mar 8, 2019 at 8:37
  • 1
    There is a pretty good article for the same. talkingdotnet.com/… Commented Mar 8, 2019 at 13:07
  • 3
    Thanks for the info,But all these describes about using HttpClienyFactory in Asp.Net core 2.1.but how to use thisin .Net Core 2.1 class library Commented Mar 9, 2019 at 9:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.