I'm new to ASP.NET Core. I'm using ASP.NET Core 7. I read that in ASP.NET Core 7 they got rid of Startup.cs
. Can someone show me how to merge Startup.cs
into Program.cs
in this example.
I read that in ASP.NET Core 7 they got rid of Startup.cs.
Not exactly. ASP.NET Core 6 introduced a new so called minimal hosting model (which is used by the default template). But you are free to keep the generic hosting model if you want.
How to merge Startup.cs into Program.cs
In short - move everything from ConfigureServices
to before var app = builder.Build();
call and everything from Configure
- after it (check out code generated by the default template). To setup services you can use builder.Services
, configuration is accessible from both builder
and app
via correspondingly named property and use app
to perform the calls from Startup.Configure
.
See also: