Scoped

Last updated

What is Scoped?

Scoped lifetime is a type of dependency injection that creates a new instance of an object for each unique request, but reuses the same instance for the same request. This means that if multiple components within the same request depend on the same service, they will all receive the same instance. However, if another request is made, a new instance of the service will be created for that request.

Scoped lifetime is useful when you have services that are specific to a given request, such as a request-scoped database context. This allows you to have a separate and isolated instance of a service for each unique request, which can help to prevent cross-request contamination of data and improve performance.

Free resources to learn Scoped

More in stage 6: Caching

Scoped: common questions

Can I learn Scoped in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Scoped in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Scoped tutorial for beginners?

It is lesson 41 of 146 in the free ASP.NET Core roadmap, in stage 6, Caching. If you are new to ASP.NET Core, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me