.NET

ASP.NET Core Request Lifecycle

Request pipeline, middleware pipeline, filters, action results, model binding

20 питань зі співбесід·
Junior
1

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.

2

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.

3

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.

4

What are the main sources for model binding in ASP.NET Core?

5

What is the difference between IActionResult and ActionResult<T>?

+17 питань зі співбесід

Опануй .NET для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно