Service lifetime
A service lifetime is a dependency-injection rule that determines when service instances are created, how long they are retained, and when they are disposed.
ASP.NET Core in Action, 3e
A service lifetime is the dependency-injection rule that determines how long a registered service instance is retained and when it is disposed.
- How it is used
- Controls instance creation and reuse when registering application services with ASP.NET Core dependency injection.
- How deep it goes
- Defines all three lifetimes, illustrates their effect on instance reuse, and addresses manual scoped resolution and disposal.
- Examples
- Uses email-service registrations and a DataContext shared with a Repository to contrast instance reuse.
- What you can do after
- Operate/configure it by choosing transient, scoped, or singleton registration and creating a scope for manual scoped resolution.
Read how ASP.NET Core in Action, 3e explains service lifetime →
Pro ASP.NET Core 7, Tenth Edition
A service lifetime is the dependency-injection rule governing when service instances are created and how long they are retained.
- How it is used
- Configures dependency-injection instance boundaries for middleware, endpoints, handlers, and other components.
- How deep it goes
- Explains transient and scoped resolution, request scopes, endpoint instantiation, manual scopes, and mixed-lifetime effects.
- Examples
- Demonstrates GuidService, endpoint handlers, middleware parameters, request-scoped resolution, and timestamping through a chained service.
- What you can do after
- Apply it via AddTransient, AddScoped, RequestServices, and CreateScope, then verify behavior through endpoint responses.
Read how Pro ASP.NET Core 7, Tenth Edition explains service lifetime →
Related concepts
- Singleton patternincludes · The Singleton pattern restricts a type or component to one shared instance within a defined scope and provides a way to access it.
- service registrationconfigured by · Service registration is the configuration that maps a requested service or interface to the implementation the dependency-injection container should provide.
- transient lifetimeincludes · A transient lifetime is a dependency-injection policy that creates a new service instance each time the service is requested or resolved.
- bean scopeincludes · A dependency-injection scope is a lifetime boundary within which a service or bean instance is created and reused, with separate instances in different scopes.
- serviceconfigures · A service is an application component that provides defined capabilities to other components through an interface.
- serviceconfigures · A service is a software or computing capability that provides defined functionality to users or other components through an interaction boundary.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

