Cleaning Up The Program.cs File In .NET 6 Now That Startup.cs is Gone |
|
With ASP.NET Core in .NET 6, we lost the Startup.cs file. All of that functionality was moved into the Program.cs file, and while it was consolidated, the Program file can get quite large. In this video, we will look at techniques to keep the Program.cs file clean and focused. We will use a Minimal API since that project type is the worst offender here, but these techniques will apply to all ASP.NET Core project types, as well as to other projects in the C# ecosystem.
Full Training Courses: https://IAmTimCorey.com Source Code: https://leadmagnets.app/?Resource=ProgramCleanup Mailing List: https://signup.iamtimcorey.com/ 0:00 - Intro 1:18 - Getting Started: Creating ApiDemo(ASP.NET Core Web API) 3:12 - Program.cs 4:32 - Services(Dependency Injection) 5:01 - Swagger 5:58 - Minimal APIs actions(Endpoints) 8:15 - Refactor Services(Dependency Injection) 14:39 - Refactor Swagger 17:14 - Refactor Minimal APIs(Endpoints) 22:14 - Cleaning up MS Sample code 22:54 - Recap |