.Net Core 8.0 Pipeline

In .Net core 8.0 we do not have startup.cs and all things merged into Program.cs

Program.cs in. Net 8.0

var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();

Key points

a. Earlier we had program.cs and statup.cs separately and program.cs take responsibility to load application setting / Logging/IIS profile etc which do not need to change everytime but startup.cs contains setting related to application DI container , Application pipleline and Middleware’s

b. In .Net8.0 we have only program.cs and responsible for application bootstrap

c. We can Add Services using builder.Services

Here we can do DI

d. Adding Configuration using builder. Configuration.

Configure Logging using builder

e. We can use below code for Middle ware

var app = builder.Build();

here app is object of Web Application class which take responsibility for middleware /pipeline

f. When we run this application all setting get loaded into builder object



Below things get loaded when we run application.

i) Configuration

ii) Logging

iii) Env variables

iv) DI services

v) Host related settings


line

Copyrights © 2024 letsupdateskills All rights reserved