
ASP.NET Core Request Lifecycle
Request pipeline, middleware pipeline, filters, action results, model binding
1What is the main role of the request pipeline in ASP.NET Core?
What is the main role of the request pipeline in ASP.NET Core?
답변
The request pipeline sequentially processes each HTTP request through middlewares configured in Program.cs. Each middleware can inspect, modify, or short-circuit the request before passing it to the next one. This chain-of-responsibility pattern allows separation of concerns (authentication, logging, compression, etc.) and modular composition of request processing.
2What is the importance of middleware order in the ASP.NET Core pipeline?
What is the importance of middleware order in the ASP.NET Core pipeline?
답변
Middleware order is critical because requests are processed top-to-bottom, then responses travel back bottom-to-top. Placing authentication middleware after routing will cause security issues as endpoints will be exposed without verification. Typical order is: Exception Handling → HTTPS Redirection → Static Files → Routing → CORS → Authentication → Authorization → Endpoints.
3How can a middleware short-circuit the request pipeline?
How can a middleware short-circuit the request pipeline?
답변
A middleware can short-circuit by not passing the request to the next middleware via next(). This is useful for authentication middlewares returning 401 Unauthorized, serving static files without invoking routing, or implementing caching that returns cached responses without executing business logic. Short-circuiting improves performance by avoiding unnecessary middleware execution.
What are the main sources for model binding in ASP.NET Core?
What is the difference between IActionResult and ActionResult<T>?
+17 면접 질문