.NET
29 posts tagged “.NET”.
October 2026
-
Agentless logging from .NET to Datadog
You don't need to install the Datadog Agent to get your .NET logs into Datadog. Two agentless options send them straight over HTTPS, structured and ready to search.
September 2026
-
Pass your CancellationToken all the way down
When a caller gives up on a request, your code should stop working on it too. It only takes a parameter, but you have to pass it through every layer.
-
CQRS without the ceremony
CQRS often arrives with separate databases, event sourcing and a mediator library. The core idea is much simpler and useful on its own: write through your domain model, read with plain queries.
August 2026
-
Parse text without allocating with Span<T>
Splitting a line with
string.Splitcreates a new string for every field. For large files,ReadOnlySpan<char>lets you parse the same data with almost no allocations. -
MongoDB indexes from C#, and how to know you need one
A query that's fast with a thousand documents can scan millions in production. Here's how to create indexes from the C# driver, order their fields, and check that queries actually use them.
July 2026
-
Every outbound call needs a timeout
The default HttpClient timeout is 100 seconds, far longer than anyone waiting on you. Set timeouts deliberately, layer them so they make sense together, and pass cancellation through.
June 2026
-
Test time-dependent code with TimeProvider
Code that calls
DateTime.UtcNowdirectly is hard to test. Since .NET 8,TimeProvidergives you a standard abstraction, and a fake one that you can move forward on demand.
May 2026
-
Do you still need ConfigureAwait(false)?
In ASP.NET Core application code, no. In libraries, yes. Here's why the answer depends on where your code runs.
-
Share blobs with user delegation SAS tokens
A SAS token signed with the storage account key can't be revoked without rotating the key. A user delegation SAS is signed with Entra ID credentials, expires sooner and fits with managed identity.
-
Integration tests against a real database
The EF Core in-memory provider doesn't behave like SQL Server, so tests pass and production fails. WebApplicationFactory plus Testcontainers lets you test the real thing.
April 2026
-
Primary constructors and their surprises
Primary constructors on classes save a lot of boilerplate for dependency injection. Their parameters aren't readonly fields, though, and that has consequences.
-
Paging through data without skipping records
Offset paging quietly skips or repeats records when data changes mid-sync. Cursor and keyset paging don't, whether you're calling an API or building one.
March 2026
-
Faster JSON with System.Text.Json source generation
By default, System.Text.Json uses reflection to work out how to serialize your types. A source generator can do that work at compile time instead, for faster startup and trimming support.
-
Follow one request across every service
When a request passes through an API, a queue and two background workers, you need one ID that ties all the logs together. .NET already creates it for you.
-
Stream results with IAsyncEnumerable
Loading 100,000 rows into a list before sending the first one wastes memory and time.
IAsyncEnumerable<T>lets you process and return items as they arrive.
February 2026
-
Upgrading from .NET 8 to .NET 10
.NET 8 support ends in November 2026, and .NET 10 is the next long-term support release. Here's a checklist for moving production services without surprises.
-
Circuit breakers stop you hammering a failing service
Retries help with brief failures. When a dependency is down for minutes, retries just pile on. A circuit breaker notices and fails fast until it recovers.
-
Moving Azure Functions to the isolated worker model
Support for the in-process model ends in November 2026. The isolated worker model is where new .NET versions and features land, and the move is mostly mechanical.
-
Stop using async void and fire-and-forget
async voidcan crash your process, and_ = Task.Run(...)in a web request quietly loses errors and uses disposed services. Here's what to do instead.
January 2026
-
Structured logging that you can actually query
A log message built with string interpolation is just text. A message template turns every value into a field you can filter and chart in Application Insights.
-
Turning on nullable reference types in an existing codebase
Nullable reference types catch null reference exceptions at compile time. Switching them on in a large, older project produces thousands of warnings. Here's how to adopt them one step at a time.
December 2025
-
ValueTask: when to use it and when not to
ValueTask<T>can save an allocation on hot paths. It also comes with rules thatTaskdoesn't have, and breaking them causes bugs that are hard to trace.
November 2025
-
Handling 429 Too Many Requests
When an API says you're sending too much, it usually tells you how long to wait. Respect that, slow yourself down, and your integration stops getting throttled.
-
IOptions, IOptionsSnapshot or IOptionsMonitor?
The options pattern has three interfaces that look almost identical. Picking the wrong one means settings that never reload, or a startup crash.
-
Start with a modular monolith
Microservices solve problems most new systems don't have yet. A modular monolith gives you clean boundaries now and an easy path to split later, if you ever need to.
-
DI lifetimes and the captive dependency trap
A singleton that holds on to a scoped service keeps it alive forever. It's one of the easiest bugs to create in ASP.NET Core and one of the hardest to spot.
October 2025
-
Use managed identity instead of connection strings
Connection strings with keys end up in config files, pipelines and screenshots. Managed identity lets your Azure app authenticate with no secret at all.
-
Retries with exponential backoff and jitter
Retrying a failed call is easy. Retrying it without making the outage worse takes backoff, jitter and some care about which requests are safe to repeat.
-
Records vs classes in C#
Records give you value equality,
withexpressions and a one-line declaration. Here's when that helps, and the two places it quietly bites.