In C# if you’re referencing property, class or namespace names in your code use the nameof() expression rather than strings … Continue reading In C# use the nameof() expression so your property, class and namespace references are type safe
Category: .NET Core Blog
In C# use Math.Clamp to force a number between a particular inclusive range
In C# Math.Clamp is a helpful method if you need to force a value to stay within a particular inclusive … Continue reading In C# use Math.Clamp to force a number between a particular inclusive range
StringBuilder performance can be improved in C# by setting its capacity
When using StringBuilder in .NET most of times we likely just use the default constructor StringBuilder()… BUT if we have … Continue reading StringBuilder performance can be improved in C# by setting its capacity
.NET 6 string concatenation performance benchmarks
Since there’s been so many amazing performance improvements in .NET 6 I thought it would be fun to compare different … Continue reading .NET 6 string concatenation performance benchmarks
How to use Azure Cache for Redis in a .NET Core web app
If you need a distributed cache and are planning on deploying your .NET Core web app to Azure, using Azure … Continue reading How to use Azure Cache for Redis in a .NET Core web app
Override the default controller scaffold templates in Visual Studio 2019 and .NET 5.0
The real power of scaffolding in Visual Studio comes from the ability to override the templates which are used to … Continue reading Override the default controller scaffold templates in Visual Studio 2019 and .NET 5.0
Enabling view refresh after .CSHTML changes for new projects in Visual Studio
Since .NET Core 3.0 your views in MVC won’t refresh after you change your .CSHTML markup. You can enable this … Continue reading Enabling view refresh after .CSHTML changes for new projects in Visual Studio
Using ToLower() or ToUpper() in C# to compare strings is not safe in all cultures
If you’re using Resharper, Roslynator or similar you’ll likely see string comparisons using ToLower() or ToUpper() flagged. Why are these … Continue reading Using ToLower() or ToUpper() in C# to compare strings is not safe in all cultures
Filtered includes now supported in Entity Framework Core 5.0
Filtered includes is an awesome new feature in Entity Framework Core 5.0 which was released in November 2020. Without lazy … Continue reading Filtered includes now supported in Entity Framework Core 5.0
Easier immutability with Init only properties in C# 9
C# 9 shipped with .NET 5 in November. One change included is init only properties which allow us to have … Continue reading Easier immutability with Init only properties in C# 9
Running framework-dependent .NET 5.0 apps in Azure App Service before RTM
.NET 5 Release Candidate 1 (of 2) has just dropped. Prior to its full release and availability as a built … Continue reading Running framework-dependent .NET 5.0 apps in Azure App Service before RTM
Reading Entity Framework Core connection string from appSettings.json
When you run Scoffold-DbCotext with a connection string EF Core will scaffold your DB but will put the hardcoded connection string … Continue reading Reading Entity Framework Core connection string from appSettings.json
Setting Brotli compression level when using response compression in ASP.NET Core
Brotli compression can compress HTML, CSS and JS files more versus Gzip compression. If you can’t enable Brotli compression on … Continue reading Setting Brotli compression level when using response compression in ASP.NET Core
Creating a DTO class from a JSON string in Visual Studio
If you’ve got back some JSON from a REST API you’ll likely be wanting to use Newtonsoft or System.Text.Json (.NET Core … Continue reading Creating a DTO class from a JSON string in Visual Studio
Extracting Google PageSpeed performance score in .NET
Most webmasters are aware that Google uses performance as a ranking signal for both desktop and mobile searches so its important … Continue reading Extracting Google PageSpeed performance score in .NET
Parsing a nested value from a JSON string in .NET Core 3 without needing a DTO
.NET doesn’t use Newtonsoft by default anymore (since .NET Core 3.0). A lot of the examples online show how to use … Continue reading Parsing a nested value from a JSON string in .NET Core 3 without needing a DTO