Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Understanding Program.cs & Startup.cs File

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:

A screen shot of a computer program

AI-generated content may be incorrect.

 

 

Program Running Flow:



Post a Comment

0 Comments