HttpClientFactory Implementation in MVC specifically in non .Net Core Projects ?
Using of HttpClient is .Net is quite common. Most of the developers do it un-intentionally even without knowing its consequences. Once your product went too productions and Users start using it, Boom...! the maintenance or devops guys will be in trouble due to the Port exhaustion Issue . If your application is on Cloud, it will cost you so much as resources consumption is more and not only that it will directly affect the performance of your application. Aaaaah...! One small thing can create such major issues and yes don't forget the escalation from your client. So, What's the Solution...! Bingo the one which bring you on this blog, the implementation of HttpClientFactory instead of HttpClient. Using DI, HttpClientFactory will only create a single instance and use the same while calling any API unlikely the HttpClient and thus solving your major problems in few seconds. It's quite easy when it comes to .Net Core, you have to just add one Library and it starts working. But ...