How To

How to use Polly In C#
3/13/2025 2:27:10 AM  270

To use Polly in C#, you'll need to install the Polly NuGet package and implement it in your code for retry, circuit breaker, timeout, and other resiliency patterns.

Global exception event handlers in C#
3/12/2025 4:25:22 AM  96

In .NET applications, there are two essential global exception events that can help you manage errors:

How to Add or overwrite a value in ConcurrentDictionary in C#
3/12/2025 4:02:31 AM  131

The ConcurrentDictionary is a thread-safe collection, which allows you to safely add, retrieve, or modify items from multiple threads. You can use the indexer to add or overwrite a value easily, but there are times when you might want to handle your operations more selectively depending on your requirements.

Handling Posted Form Data in an API Controller
3/12/2025 3:54:47 AM  94

To capture posted form data in an API Controller (using the [ApiController] attribute) in ASP.NET Core, use parameters with the [FromForm] attribute.

How to Add a custom action filter in ASP.NET Core
3/12/2025 3:41:14 AM  103

Action filters in ASP.NET Core provide a way to inspect HTTP requests before they reach the action method and responses before they are sent back to the client.

How to Get all classes with a custom attribute in C#
3/12/2025 3:31:34 AM  133

To find all classes with a custom attribute, the first step is to gather all types within the assembly and then use the IsDefined method to filter the types that are marked with the custom attribute.

How to Map query results to multiple objects with Dapper in C#
3/12/2025 3:21:06 AM  157

When dealing with SQL queries that join multiple tables, Dapper's multi-mapping feature allows you to map the results to multiple objects. This can be really handy when you're pulling related data in a single query.

How to Update appsettings.json in C#
3/12/2025 3:05:13 AM  275

To update values programmatically within a settings JSON file, you will need to overwrite the entire settings.json file.

Injecting ILogger into Dapper Polly Retry Policy in C#
3/11/2025 8:49:16 AM  157

To inject ILogger into a Dapper Polly Retry Policy in C#, you can follow these steps.

Properly Disposing HttpContent When Using HttpClient in C#
3/11/2025 8:27:15 AM  87

In versions prior to .NET Core 3.0 (including .NET Framework), database connection pooling was automatically managed by the framework, with the connection object being disposed of at the end of each operation.

How to send a file with HttpClient in C#
3/11/2025 8:14:25 AM  175

When uploading a file with HttpClient, you need to place the file inside a MultipartFormDataContent object, which will be sent as the body of the HTTP request.

How to Deserialize JSON with quoted numbers in C#
3/11/2025 8:02:13 AM  113

In JSON, numbers can be represented in two main formats: as literal numbers (e.g., 123) or as quoted strings (e.g., "123").