With .Net 6
, Microsoft unified Program.cs
and Startup.cs
class files
So now in .Net 6+, we can have the Startup.cs file's code in Program.cs only
There were two main use cases of Startup.cs
ConfigureServices
methodConfigure
methodYou will see a line in Program.cs in .Net 6+
var app = builder.Build();
Technically, this line is the separator of ConfigureServices and Configure method
builder.Services
to register the service dependencies, and builder.Configuration
to access configuration from appsettings or environment variables)app.Services
to access the IServiceProder
to resolve any dependency and app.Configuration
to access configuration from appsettings or environment variables)No comments yet. Be the first to leave a comment