Microsoft.Extensions.Http
// Register IHttpClientFactory in ConfigureServices method services.AddHttpClient(); // Inject IHttpClientFactory in the constructor public class MyController : Controller { private readonly IHttpClientFactory _httpClientFactory; public MyController(IHttpClientFactory httpClientFactory) { _httpClientFactory = httpClientFactory; } public async TaskIn this example, we have registered IHttpClientFactory in the ConfigureServices method and injected it in the MyController constructor. We have then created an HttpClient instance using IHttpClientFactory and used it to make a GET request to a remote API. Finally, we have returned the response as JSON. Overall, IHttpClientFactory simplifies the process of creating and managing HttpClient instances in .NET Core applications and improves performance.Index() { // Create an HttpClient instance from IHttpClientFactory var client = _httpClientFactory.CreateClient(); // Make a GET request to a remote API var response = await client.GetAsync("https://jsonplaceholder.typicode.com/posts"); // Read the response content string content = await response.Content.ReadAsStringAsync(); // Return the response as JSON return Content(content, "application/json"); } }