Understanding the Program.cs File in Newer Versions of ASP.NET
Learn to understand the backend entry points of the project in the latest version of .NET.
We'll cover the following
In this lesson, we will see how we can migrate the ASP.NET application to the latest version. We are using .NET 7. In newer versions, the Startup.cs
and Program.cs
files have been merged into a single file called Program.cs
with the following changes:
ConfigureServices
is replaced withWebApplication.Services
.builder.Build
()
returns a configuredWebApplication
to the variableapp
.Configure
is replaced with configure calls to the same services usingapp
.
The Program.cs
file
The new Program.cs
file is given as follows in which WebApplication.CreateBuilder
method creates a new instance of the WebApplicationBuilder
class, which is used to configure the application’s services and request/response pipeline.
The new file will come here:
Get hands-on with 1400+ tech skills courses.