ASP.NET Core correct usage of ConfigureAwait with async/await

Lately we had a discussion on when to use ConfigureAwait(true) or ConfigureAwait(false) in ASP.NET Core 2. In the end most of the team, including me, had a faulty assumption on how to do this in ASP.NET Core. In this case ASP.NET Core is different from ASP.NET. Good to know if you have to decide on what to use in ASP.NET core.

Continue reading “ASP.NET Core correct usage of ConfigureAwait with async/await”

Application Shutdown in ASP.NET Core 6/8

In .NET 6 and 8, gracefully handling application shutdown is crucial for releasing resources or completing ongoing tasks before the application ends. The IApplicationLifetime interface was deprecated in favor of IHostApplicationLifetime in ASP.NET Core 3.0, and this approach continues in .NET 6/8.

1. Add IHostApplicationLifetime to your service

In modern ASP.NET Core applications, IHostApplicationLifetime is injected into services, such as controllers or services where you need to handle shutdown events.

Continue reading “Application Shutdown in ASP.NET Core 6/8”