logo

,

Startup.cs Missing in .Net 6 and Above

Let’s discuss in this article the changes in .Net 6 with the missing Startup.cs file. So let’s get started.

We .Net core developers are very familiar with the Startup.cs file, the ConfigureServices & the Configure methods in the Startup.cs file. Now, Let me tell you that you will not find the Startup.cs file from .Net 6 onwards. So, what happened to our so important Startup.cs file in .Net 6?

For this, I will be creating two Asp.net core MVC web applications. One in .Net 5 and the other in .Net 6. We will compare these two projects side by side and understand what has happened with the Startup.cs file.

Comparison

As you can see from the above screenshot of both the .Net 5 and .Net 6 projects, the Startup.cs file is missing in the .Net 6 project. Now, what happened here in .Net 6 is the Startup.cs file has been moved into the Program.cs file. Or we can say that the contents of the Startup.cs of .Net 5 have been moved to Program.cs in .Net 6.

.Net 5 Startup.cs vs .Net 6 Program.cs

Files Comparison

  1. In .Net 6 we create the builder in the Program.cs file and under the builder we add the service to the container. So whatever we have in the ConfigureServices method in the .Net 5 Startup.cs those entries go and get added under the builder services in .Net 6 Program.cs.
  2. In .Net 5 we had the Configure method in the Startup.cs where we add items to the request pipeline. Now with .Net 6 whatever we have in the Configure method in .Net 5 Startup.cs. Those entries are also in the same Program.cs file in .Net 6, below the “Configure the HTTP request pipeline” comment.

This is a very small change but I wanted to make sure that my fellow programmers are aware of this change.

Don’t forget to check out Learn Mobile App Development with .NET MAUI

Don’t forget to check out Generate QR Code in Asp.net Core with 4 Simple Steps

 

Share on facebook
Share on twitter
Share on linkedin

Related articles