ASP.NET Core & Web API (50 Qs)•Part 2: Entity Framework Core, Security & High-Performance Data (11 - 24)
How do you implement Graceful Shutdown on .NET Web Apps?
junior LevelFormsPerformanceSecurity & Auth
In Simple Words:
When receiving SIGTERM:
- Host triggers
IHostApplicationLifetime.ApplicationStopping. - Kestrel stops accepting new connections.
- In-flight requests are allowed to complete up to
HostOptions.ShutdownTimeout(default 30s). IHostedService.StopAsyncis invoked sequentially on all background workers.