In this tutorial, we are going to cover different topics related to using HttpClient with ASP.NET Core. We are going to learn, how to use HttpClient in different scenarios, and with each article, we are going to improve our solution. Thus, making HttpClient usage even more optimized and faster. Also, we will learn how to use IHttpClientFactory to solve some problems that HttpClient can cause.
To follow along with this tutorial, you should:
Our Tutorial Will Consist of the Following Topics
- Fetching Data and Content Negotiation with HttpClient in ASP.NET Core
In this article, we are going to learn how to integrate and use HttpClient in ASP.NET Core Applications. We are going to consume the Web API’s resources while learning about different HttpClient functionalities. We are going to learn how to fetch data from Web API and how to use the HttpRequestMessage class directly to accomplish that.
- POST, PUT, and DELETE Requests Using HttpClient in ASP.NET Core
In this article, we are going to learn how to send POST, PUT and DELETE requests using HttpClient in ASP.NET Core. We are going to show you both examples for each request with shortcut methods (PostAsync, PutAsync, DeleteAsync) and with the HttpRequestMessage class.
- Using HttpClient to Send HTTP PATCH Requests in ASP.NET Core
In this article, we are going to show you how to use HttpClient to send HTTP PATCH requests to achieve partial updates of our resources, thus improving the application’s performance.
- Using Streams with HttpClient to Improve Performance and Memory Usage
In this one, we are going to learn how to use streams with HttpClient while sending requests and reading the content from responses. We are going to use streams with only the GET and POST requests because the logic from the POST request can be applied to PUT, and PATCH.
- Canceling HTTP Requests in ASP.NET Core with CancellationToken
With this one, we are going to learn how to use CancellationToken to cancel HTTP requests in our client application.
- Using HttpClientFactory in ASP.NET Core Applications
In this article, we are going to learn how to centralize HttpClient’s configuration by using HttpClientFactory. Additionally, we are going to learn how HttpClientFactory prevents additional problems that HttpClient can cause. Furthermore, we are going to show you how to create named and typed clients using HttpClientFactory.
After this Tutorial
You will have an excellent knowledge of using HttpClient in ASP.NET Core applications and will understand all the concepts required to write great API-consuming applications.
As you see a lot of ground to cover.
So, let’s get started.