Program.cs File:
Program.cs is the main entry point of a .NET Core
application. It sets up and runs the web host and configures services and
middleware (especially in .NET 6+ using the minimal hosting model).
Purpose:
-
📍 Starts the web server (Kestrel)
-
🔧 Registers services like
controllers, logging, DB context.
-
🛣️ Sets up the HTTP
request pipeline.
Example:
Startup.cs File:
Startup.cs is a class used to configure services and the
HTTP request pipeline in .NET Core (mostly in .NET Core 3.1 and .NET 5 apps).
- This file is your application control center , controlling its setup & behaviour.
- It defines how your application interacts with database, middleware & external services through ConfigureServices & Configure Methods.
- It also enables Dependency Injections.
-
Purpose:
-
🛠️ ConfigureServices()
→ Registers app services like controllers, DB context, etc.
-
🛣️ Configure() → Sets
up middleware (like routing, error handling, etc.)
Example:
Program Running Flow:
0 Comments
If you have any queries, please let me know. Thanks.