.NET & C# · Web API
How would you answer an interview scenario involving dependency injection in APIs in Web API?
I would keep the controller or minimal API endpoint thin: it handles HTTP concerns, calls an application service, and maps the result to an HTTP response. The application service owns the use case and depends on abstractions for persistence or external systems. I would register services with lifetimes that match their behavior, keep DbContext scoped, and avoid service-locator patterns or large controllers containing business logic.