vrijdag 3 mei 2019

asp.net core service lifetime for DI

Service Lifetimes:


  1. Transient
  2. Scoped
  3. Singleton



Transient
Every request from the service container, it will be recreated.

Not to be confused with every controller request. but if in the pipeline of your request it is provided in multiple constructors and those are called from the service container, it will be instantiated as a new instance

Scoped
The object is instantiated once per client request / per connection

Singleton
The object is instantiated only once for all client calls.


Geen opmerkingen:

Een reactie posten