Statistics
The Highest Post







Statistics
Count 94
Avg 21.00
Min 21
Max 21
Angualr Top questions

Details



What are the three major lifetimes In dependency injection in NET's AddSingleton creates a single instance of request throughout the application. It creates the instance for the first time and reuses or share the same object in the all calls. <br><br> AddScoped creates once per request and allow you to share the state throught out to the user without worrrying of creating a ne one. It is equivalent to a singleton in the current scope. For example, in MVC it creates one instance for each HTTP request, but it uses the same instance in the other calls within the same web request. <br><br> AddTransient lifetime services creates instances each time they are requested or new instance any time they are requeted but not sharedthe old one. Shorted life span. This lifetime works best for lightweight, stateless services.
Related Topics