Two features quietly shape every ASP.NET Core application: dependency injection and configuration. Instead of creating its own collaborators, a class asks for what it needs and the built-in DI container supplies it — which keeps code loosely coupled and easy to test. Configuration does the same for settings, layering values from files, environment variables, and secrets.
This module starts with dependency injection and service
lifetimes — singleton, scoped, and transient — followed by a lesson on
the classic pitfall of injecting a scoped service into a singleton. It then covers
reading appsettings.json with IConfiguration and the
options pattern, and finishes with user secrets,
so sensitive values never end up in source control.
Watch the lessons in order, then continue on to Middleware & the Request Pipeline.
A walkthrough of dependency injection in ASP.NET Core that breaks down the singleton, scoped, and transient lifetimes, how each works, and when to use each.
Most services can inject other services regardless of lifetime, but not all combinations are safe. This lesson explains why a singleton can't safely depend on a scoped service.
Compares injecting IConfiguration, IOptions, and IOptionsSnapshot into your API controller to read settings, so you can choose the right approach.
Shows how to keep passwords, API keys, and connection strings out of appsettings.json using the dotnet user-secrets CLI, where secrets.json is stored, and how ASP.NET Core loads secrets automatically in Development.