IServiceCollection Access

Hanaa Gebril 1 Reputation point

How can I access IServiceCollection from web api or controller?

A set of technologies in the .NET Framework for building web applications and XML web services.
4,281 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Lohith GN 511 Reputation points

    @Hanaa Gebril

    Not sure what you are trying to achieve. You will need to provide more explanation on your question.

    The concept of IServiceCollection is - its a container which is built up at the start of your app. You register components with the collection with lifetime specified (Singleton, Scoped etc). Once your app starts and container is built with all your dependent components, you just ask for the component you need through your constructor dependency. ASP.NET Core makes sure that whatever dependency a class is asking for will be picked up from your container and provided to the class. Thats DI & IoC principle in play...

    So when you say i want to access IServiceCollection - what for ?

    0 comments No comments