.NET tutorials

How to create and add custom middleware in ASP.NET Core

How to create and add custom middleware in ASP.NET Core

Find out how to create custom middleware using C# and add it to a .NET app by adding HTTP response headers to an ASP.NET Core Web API request.
Exception handling has its own middleware in .NET 8

Exception handling has its own middleware in .NET 8

Exception handling in C# has improved dramatically with the launch of it's own IExceptionHandler middleware in .NET 8 .
Validating appsettings becomes much faster with .NET 8

Validating appsettings becomes much faster with .NET 8

.NET 8 allows for a faster way to validate the option values in appsettings.json in an ASP.NET Core Web API using data annotations.
Hosted service has a major update to its lifecycle events

Hosted service has a major update to its lifecycle events

The worker service project sees a major update in .NET 8 with the new IHostedLifecycle interface hooking into new background hosted service lifecycles.
Data annotations has some awesome additions in .NET 8

Data annotations has some awesome additions in .NET 8

Model validation for ASP.NET Core Web API now includes data annotations such as allowed and denied values as well as Base64 string validation.
TimeProvider makes it easier to mock time in .NET 8

TimeProvider makes it easier to mock time in .NET 8

The TimeProvider abstract class can be used in xUnit unit tests to mock the time and a timer using the FakeTimeProvider in .NET 8.
Collection expressions brings the spread operator to C# 12

Collection expressions brings the spread operator to C# 12

Collection expressions (also known as collection literals) brings the spread operator to C# allowing for collection types to be joined together.
Render mode for Server & WebAssembly Blazor components

Render mode for Server & WebAssembly Blazor components

Blazor has a .NET 8 render mode feature that allows different modes to be set for Razor components in the same app whether it's Server, WebAssembly or Auto.
Server-side rendering (SSR) for Blazor in .NET 8

Server-side rendering (SSR) for Blazor in .NET 8

Server-side rendering (SSR) is a render mode which has become a new Blazor feature for .NET 8, working in a similar way to ASP.NET Core MVC.
Primary constructors adds class parameters in C# 12

Primary constructors adds class parameters in C# 12

Primary constructors is a C# 12 feature that allows to add parameters to a class and includes dependency injection support.