scope validation
A container check that fails when a singleton depends on a scoped service, a bug called a captive dependency.
In more detail
It is on by default in the Development environment. Without it, the scoped object would outlive its request and leak state across users.
Related terms
- singleton — A service lifetime, or design, in which one instance is created and shared for the whole life of the process.
- scoped lifetime — A service lifetime in which one instance is shared within a scope, which in ASP.NET Core means one HTTP request, then disposed.
- service lifetime — How long the container keeps and reuses an instance of a service: transient, scoped or singleton.
Taught in
- The Dependency Injection Container: Scopes and Lifetimes — Modern .NET Core, C# & Enterprise Microservices
- The Options Pattern: Strongly Typed Configuration — Modern .NET Core, C# & Enterprise Microservices