Search

How to send a file using HttpClient in C#
By Tan Lee Published on Jan 22, 2025 465

When working with HTTP requests in C#, one common task is sending files through a POST request.

Read more
Sending query strings using HttpClient in C#
By Tan Lee Published on Jan 21, 2025 506

Query strings consist of a ? followed by one or more key-value pairs separated by &. It is essential to ensure that special characters, such as spaces or Unicode characters, are properly encoded.

Read more
How to change the HttpClient timeout per request in C#
By Tan Lee Published on Jan 21, 2025 711

When making multiple requests with a shared HttpClient instance, you may sometimes need to modify the timeout for specific requests.

Read more
Handling Redirects with HttpClient in C#
By Tan Lee Published on Jan 21, 2025 425

By default, HttpClient handles redirects automatically. When a request results in a 3xx response code (e.g., 301, 302), HttpClient follows the Location header and makes a new request to the provided URL.

Read more
How to read problem details JSON using HttpClient in C#
By Tan Lee Published on Jan 21, 2025 681

Problem details (RFC7807) is a standardized format for error responses, which uses the `Content-Type` of `application/problem+json`, an appropriate HTTP status code (e.g., 400 – Bad Request), and a response body structured as follows:

Read more
How to Cancel an HttpClient Request in C#
By Tan Lee Published on Jan 21, 2025 268

In C#, you can achieve this by using the CancellationToken with the HttpClient class.

Read more
C# Async Main
By Tan Lee Published on Jan 21, 2025 218

The Async Main feature, introduced in C# 7.1, allows you to make the Main() method asynchronous.

Read more
The referenced component could not be found
By Tan Lee Published on Jan 21, 2025 357

When opening a C# project in Visual Studio, you may encounter a frustrating error where none of the references load correctly.

Read more
Fixing the Sync over Async Antipattern in C#
By Tan Lee Published on Jan 21, 2025 241

One common mistake developers make is the Sync over Async antipattern, which occurs when blocking waits are used in asynchronous methods instead of awaiting them properly.

Read more
C# Add to a Dictionary
By Tan Lee Published on Jan 21, 2025 271

The simplest way to add a key-value pair to a dictionary is by using Dictionary.Add().

Read more