What is dependency injection?
Dependency injection supplies a class's dependencies from outside instead of constructing them internally. ASP.NET Core has a built-in service container.
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 1057–1068 of 3610 questions
Dependency injection supplies a class's dependencies from outside instead of constructing them internally. ASP.NET Core has a built-in service container.
Transient creates a new instance each time it is requested; scoped creates one instance per scope, typically an HTTP request; singleton lives for the servi
A captive dependency occurs when a long-lived service captures a shorter-lived dependency, such as a singleton holding a scoped DbContext. This can cause s
The options pattern binds configuration to a typed class and supports validation and different lifetimes through IOptions, IOptionsSnapshot, and IOptionsMo
Configuration can come from JSON files, environment variables, command-line arguments, secret stores, and custom providers. Later providers can override ea
appsettings.json provides baseline settings. Environment variables are useful for deployment-specific overrides and secret injection by the hosting platfor
Use exception-handling middleware or IExceptionHandler to map unexpected exceptions to consistent ProblemDetails responses. Log details internally and avoi
ProblemDetails is a standard representation for HTTP API errors, with fields such as type, title, status, detail, and instance. ASP.NET Core can generate i
Model binding maps route values, query strings, headers, and request bodies to action parameters or model properties. Validation runs after binding for sup
Validation uses attributes such as [Required], [Range], and custom validators. With [ApiController], invalid model state normally produces an automatic 400
IActionResult can represent many HTTP responses. ActionResult<T> combines a typed success result with alternative IActionResult responses and improves API
DTOs define what the API accepts or returns. They avoid exposing database entities directly and let the API evolve without leaking internal persistence det