Code execution order

The Startup class is executed only once during an application's lifespan, right after the web server has loaded the ASP.NET Core application.

The following screenshot shows the order of execution of the different methods in the classes involved in ASP.NET Core initialization:

The Startup class is not the place to put any code other than initialization and configuration code.

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.