Explain the Application Lifetime events in ASP.NET Core (IHostApplicationLifetime).

Junior .NET Core

Answer

IHostApplicationLifetime (renamed to IHostApplicationLifetime / IHostApplicationLifetime in newer versions) exposes three key notifications:

  • ApplicationStarted – Fired when the app is fully started and ready to serve requests.
  • ApplicationStopping – Fired when the app begins a graceful shutdown (e.g., SIGTERM in containers).
  • ApplicationStopped – Fired when shutdown is complete and cleanup has finished.

These events are used to warm up caches, start or stop background tasks, flush logs, and release resources in cloud and container environments.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice