ASP.NET Core Interview Question #37
What happened to Startup.cs in modern ASP.NET Core?
Application Structure & Configuration Junior Beginner
Quick Interview Answer
Older ASP.NET Core templates commonly used Startup.cs with ConfigureServices() and Configure() methods. Modern templates use the minimal hosting model and place equivalent configuration in Program.cs.
Detailed Explanation
Older ASP.NET Core templates commonly used Startup.cs with ConfigureServices() and Configure() methods. Modern templates use the minimal hosting model and place equivalent configuration in Program.cs.
Startup.cs is not inherently invalid. Existing applications can still use patterns based on Startup, but new projects usually use WebApplicationBuilder and WebApplication.
When migrating older applications, service registrations from ConfigureServices() move to builder.Services, while middleware from Configure() moves to the WebApplication pipeline after builder.Build().
Code Example
// Older style
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
}
// Modern equivalent
builder.Services.AddControllersWithViews();