Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

WebLog Posts in Category WebSockets


Categories
ASP.NET (324) .NET (175) Windows (76) JavaScript (72) jQuery (61) Visual Studio (54) IIS (48) Csharp (47) WPF (47) HTML (46) AJAX (45) ASP.NET (33) Localization (32) LINQ (30) WCF (28) MVC (26) Personal (25) Security (23) HTML5 (23) FoxPro (22) CSS (21) Angular (20) C# (19) Web Services (19) Web Api (16) COM (16) ADO.NET (15) Vista (11) XML (11) Sql Server (10) HTTP (10) IIS7 (10) Markdown (9) WebView (9) Microsoft AJAX (8) IIS7 (7) West Wind Ajax Toolkit (7) Web Connection (7) Entity Framework (6) Html Help Builder (5) Mobile (5) Markdown Monster (5) Live Writer (5) Internet Explorer (5) C++ (5) ASPNET5 (5) OWIN (5) Web (5) Software Development (5) SignalR (5) NuGet (5) WinForms (5) Westwind.Globalization (4) Silverlight (4) Source Control (4) Cordova (4) DataBinding (3) Conferences (3) ASP.NET Core (3) Help Builder (3) ISV (3) LetsEncrypt (3) Office (3) Opinion (3) Networking (3) Razor (3) Web Browser Control (3) WebLog (3) Web Development (2) Visual Studio Code (2) Tools (2) RegEx (2) RSS (2) Speaking (2) Linux (2) Bugs (2) Help (2) Installation (2) Dotnet (2) ASP.NET vNext (2) .NET Standard (2) Addins (2) Authentication (2) Deployment (2) Desktop (1) Credit Card Processing (1) Cross-Platform (1) CSharp Dotnet (1) Blazor (1) Blogging (1) Control Development (1) Chocolatey (1) .NET ASP.NET Windows (1) Security (1) Visual Studio (1) ADO.NET (1) ASP.NET Markdown (1) AI (1) Angular JavaScript (1) Dynamic Types (1) Email (1) FireFox (1) Flexbox (1) Git (1) Graphics (1) Hardware (1) JSON (1) IOS (1) Musings (1) Migration (1) Testing (1) Threading (1) SEO (1) rxJs (1) RazorPages (1) Travel (1) Typescript (1) VS Code (1) WebBrowser (1) WebDeploy (1) Web Deployment Projects (1) Web Design (1) Web Assembly (1) WebSockets (1) WebSurge (1) Windows-Terminal (1) Windsurfing (1) WFH (1) WPF Windows (1) WSL (1) wwHoverPanel (1)

ASP.NET Core WebSockets and Application Lifetime Shutdown Events



WebSockets in ASP.NET Core are easy to use but due to the simple model it's easy to forget that socket requests are long lived and can linger for a long time in the background and that can cause problems when an application needs to shut down cleanly. Luckily there's an `IHostApplicationLifetime` interface available that allows hooking shutdown operations and that provides the necessary cancellation tokens to allow an WebSocket connection to be terminated in response to a shutdown event. This post shows how this works.
West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024