Posts

Showing posts from August, 2025

HttpContext, Dependency Injection, Request Pipeline, Middleware in ASP.NET Core web apps explained

Image
middleware_di_httpcontext_explained ASP.NET Core is a framework to build web applications that run on .NET runtime Web Application An ASP.NET Core web application contains HttpContext object (created per HTTP request) Dependency Injection container (aka DI container) Request pipeline (bunch of middlewares) HttpContext object When a web application receives a HTTP request, it creates a HttpContext object. HttpContext object contains all the HTTP related information like HTTP request, HTTP response, session details etc. All the attributes of a HttpContext object can be found in official docs here Dependency Injection container (DI container) It is a collection of classes known Services Before running the web application, services are added (aka registered) into the web application’s DI container During registration, the lifetime of a service is declared as one of Transient , Scoped , Singleton Transient - new service instance created every ...