How To

JSON value could not be converted to System.String in C#
3/13/2025 2:50:08 AM  62

When you send a request to an ASP.NET API with a JSON body, you might encounter the following exception:

Calling ‘BuildServiceProvider’ from application code results in an additional copy of singleton services being created
3/13/2025 2:44:26 AM  54

When calling BuildServiceProvider() in your application, you may encounter this warning:

How to use Newtonsoft in ASP.NET Core
3/13/2025 2:37:33 AM  45

To use Newtonsoft.Json in an ASP.NET Core application instead of the default System.Text.Json, follow these steps:

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

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  51

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  84

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  50

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  55

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  81

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  80

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  177

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  111

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