Life cycles

Depending on the DI container we choose, we will have a larger or smaller number of life cycles available.

The more common life cycles are as following:

  • Transient: The object instance will exist in memory at the time it exists in the code block it is contained in
  • Singleton: The object instance exists in memory until it is released explicitly
  • Per request: The object instance exists in memory at the time of the HTTP request in which it is instantiated

There are lots of other life cycles avaliable, depending on the DI container we choose.

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.