Startup Class in ASP.NET Core App
The ASP.NET Core 3.1, and ASP.NET Core 5 Applications must include a Startup Class. It is like the Global.asax file our traditional .NET Application
It is executed first when the application starts.
The Startup class can be configured using UseStartup<T>() Extension method at the time of Configuring the Host in the Main() Method of the Program class
ConfigureServices() Method in ASP.NET Core Startup Class
The ConfigureServices method is a place where you can register your dependent classes with the built-in IoC container. After registering the dependent classes, it can be used anywhere in the application. You just need to include it in the parameter of the constructor of a class where you want to use it. The IoC container will inject it automatically.
The ConfigureServices method includes the IServiceCollection parameter to register services to the IoC container
Configure() Method in ASP.NET Core Startup Class
The Configure method is a place where we can configure the application request pipeline for our ASP.NET Core application using the IApplicationBuilder instance that is provided by the built-in IoC container.
ASP.NET Core introduced the middleware components to define a request pipeline, which will be executed on every request. You need to include only those middleware components which are required by your application and thus increase the performance of your application.
The default configure method of the ASP.NET Core application with the Empty Project Template includes the following three middleware components
How Do We Configure the Services and Middleware Components in .NET 6?
in .Net 6, startup file is completly removed, we can do all service & middleware registration in Main method of the Program class