How do you register services in the ASP.NET Core DI container?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jul 2, 2025, 2:06 AM EDT
Can you check this
https://www.c-sharpcorner.com/article/getting-started-with-dependency-injection-in-asp-net-core-using-c-sharp/
Jack Abroy16 reputationPosted Jul 2, 2025, 4:37 AM EDT
Use
services.AddSingletonAddScopedorAddTransientinStartup csorProgram.cs.William Gram25 reputationPosted Jul 2, 2025, 5:05 AM EDT
Use
services AddSingleton<>AddScoped<>orAddTransient<>in theConfigureServicesmethod ofStartup.cs.