Skip to main content

Explain Transient, Scoped, and Singleton lifetimes.

Mid .NET Core
Quick Answer Transient: new instance every injection รขโ‚ฌโ€ good for stateless services like email senders. Scoped: one instance per HTTP request รขโ‚ฌโ€ DbContext is the canonical example (one per request, shares a transaction). Singleton: one shared instance for the entire app lifetime รขโ‚ฌโ€ good for thread-safe, stateless services like IHttpClientFactory or caches.

Answer

Transient: new instance each request.
Scoped: one instance per HTTP request.
Singleton: one instance for entire app lifetime. Choosing correct lifetime is crucial to avoid memory leaks and race conditions.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice