Can you explain instance management in.net core?
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
Vishal JoshiRank #377 · 6.7K reputationPosted Nov 9, 2022, 2:23 AM EST
Hello,
It's just a change of words and makes the question tricky and interesting. Also, it can be asked like what are dependency injections? or what are the extension methods?
The built-in IoC container supports three kinds of lifetimes:
Singleton: IoC container will create and share a single instance of a service throughout the application's lifetime.
Transient: The IoC container will create a new instance of the specified service type every time you ask for it.
Scoped: IoC container will create an instance of the specified service type once per request and will be shared in a single request.
Thanks
Vishal YelveRank #178 · 13.6K reputationPosted Nov 9, 2022, 3:43 AM EST
Transient objects are always different; a new instance is provided to every controller and every service.
Scoped objects are the same within a request, but different across different requests.
Singleton objects are the same for every object and every request.
Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted Nov 9, 2022, 4:50 AM EST
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-7.0