Join Class

Service Configuration in Visual Studio 2022 for .Net Core

In visual studio 2022 when you create any core application, you don’t see any startup.cs file anymore, now all we have to write in program.cs file directly.

If you are working on core application using earlier version of visual studio, you probably using startup.cs file for any service configuration, now we write almost same code in program.cs

var builder = WebApplication.CreateBuilder(args);

First, let's understand how to add service in service collection list, and then using all those service in application.

var _services = builder.Services;

We can keep adding all required services (like logging, authentication, file etc) in service variable _services the same way.

As you can see in above code, we have added session to be used, now we have to tell the application to use the session.

var app = builder.Build();


If you want to see how startup file was written in earlier version of visual studio, then check following links. Core Course
Service Configuration in Visual Studio 2022 without startup file Core Tutorial for Beginners
ASP.NET MVC Interview Questions Answers
Hire .Net Developer
Asp.Net Core C# Examples | Join Asp.Net MVC Course