Skip to content
Preptima
mediumConceptScenarioMidSenior

What are the three DI lifetimes in ASP.NET Core, and what goes wrong when you inject a scoped service into a singleton?

ASP.NET Core DI lifetimes matter because a singleton that captures a scoped service turns per-request state into process-wide state. Captive dependencies cause stale data, threading bugs and disposed object failures.

4 min readUpdated 2026-08-15

Answer

Short answer

Do not inject scoped services into singletons. Keep dependencies the same lifetime or shorter from the caller's perspective, and create explicit scopes only for background work that genuinely needs scoped services.

Was this answer helpful?

Likely follow-ups

  • Why must scoped services be injected into a middleware's InvokeAsync rather than its constructor?
  • A BackgroundService needs a repository on every timer tick. How do you wire it?
  • What does ValidateOnBuild change about when a lifetime mistake is reported?
  • When is registering a service as transient rather than scoped a mistake in its own right?

Related questions

Further reading

Related Topics