Consuming anonymous types with DiagnosticListener in .NET 6
In the previous post I gave a brief introduction to the DiagnosticSource infrastructure and how you can use it to log events emitted by the .NET framework libraries. If you're new to DiagnosticSource...
View ArticleUnderstanding your middleware pipeline in .NET 6 with the Middleware Analysis...
In this post I introduce the Microsoft.AspNetCore.MiddlewareAnalysis package, and how you can use it to visualise the middleware pipeline of your ASP.NET Core apps. In this post I show how to use it...
View ArticleReturning XML from minimal APIs in .NET 6
In this post I show how you can return an XML response from a minimal API instead of the typical JSON response. I also look at ways to reduce the overhead introduced by MemoryStream in the...
View ArticleAdding content negotiation to minimal APIs with Carter
In my previous post I described how to return XML from a minimal API endpoint. In this post I look at an alternative approach, using the open source library, Carter. Content Negotiation in minimal...
View ArticleConsidering replacing Disqus with Giscus
In this post I'm soliciting opinions—should I pay to keep using Disqus for comments, or should I switch to an alternative open-source solution that uses GitHub? Commenting on blog posts Depending if...
View ArticleReplacing Disqus with GitHub discussions using giscus
In my previous post I mentioned that I was considering Disqus with a GitHub-based commenting system (for various reasons I discussed in that post, but primarily because Disqus insists on showing ads)....
View ArticleHandling concurrent merges to master in multi-stage Azure DevOps pipelines
In this post I describe a problem we were seeing in our large Azure DevOps pipeline, where a merge to master would cause PR builds to break mid-run. I describe the problem, why it occurs, and the...
View ArticleUsing CancellationTokens in ASP.NET Core minimal APIs
This post is an update to a 5 year old post about using CancellationTokens in MVC controller actions. In this post I show how you can use a CancellationToken in your ASP.NET Core minimal API endpoint...
View ArticleWorking with System.Random and threads safely in .NET Core and .NET Framework
In this post I look at some of the ways you can misuse System.Random for generating random numbers, specifically around thread safety. I start by showing how to use the built-in thread-safe Random...
View ArticleCounting the leading zeroes in a binary number with C#
I recently needed an algorithm to count the number of leading zeroes in a ulong value. In this post I describe the algorithm I used and demonstrate how it works. The requirements: count the leading...
View ArticleASP.NET Core in Action, version 3, is now available
I'm excited to announce that the third edition of ASP.NET Core in Action is available now from the Manning Early Access Program (MEAP)! 🎉 With Manning’s early access program, you get the first...
View ArticleAdding validation to strongly typed configuration objects in .NET 6
This post is a follow up to one I wrote 4 years ago about ensuring your strongly typed configuration objects bind correctly to your configuration when your app starts up. In my previous post, built...
View ArticleAdding validation to strongly typed configuration objects using FluentValidation
In my previous post I described how you could use DataAnnotation attributes and the new ValidateOnStart() method to validate your strongly-typed configuration on app startup. In this post, I show how...
View ArticleFighting with nullable reference types in Razor Pages
In this post I discuss C#'s nullable reference types in the context of Razor Pages: why the two don't play nicely together, why they probably never will, and how to make the experience a bit nicer....
View ArticleWorking with stacked branches in Git is easier with --update-refs
In this post I discuss how to use a new Git rebasing feature, --update-refs, which was included in Git 2.38, in October 2022. This makes working with "stacked" branches a lot easier. Stacked what now?...
View ArticleThe dangers and gotchas of using scoped services in OptionsBuilder
A quick reminder that my new book, ASP.NET Core in Action, Third Edition, is currently available in MEAP. Completely updated to .NET 7, minimal APIs and minimal hosting (but also covering Razor Pages,...
View Article5 new MVC features in .NET 7
Many of the headline features introduced in ASP.NET Core in .NET 7 were about minimal APIs, such as route groups and filters. But just because minimal APIs were a big focus doesn't mean that MVC...
View ArticleASP.NET Core in Action, Version 3 update
In this post I give a quick update on why my blog hasn't been as active as usual. The short answer is: I've been head down working on my new book, ASP.NET Core in Action, Third Edition! Your blog has...
View ArticleA first look behind the scenes of minimal API endpoints: Behind the scenes of...
This is the first post in the series: Behind the scenes of minimal APIs. Part 1 - A first look behind the scenes of minimal API endpoints (this post)
View ArticleExtracting metadata from a minimal API handler: Behind the scenes of minimal...
This is the second post in the series: Behind the scenes of minimal APIs. Part 1 - A first look behind the scenes of minimal API endpoints Part 2 - Extracting metadata from a minimal API handler (this...
View Article