.NET

ASP.NET Core Request Lifecycle

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

20 domande da colloquio·
Junior
1

What is the main role of the request pipeline in ASP.NET Core?

Risposta

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?

Risposta

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?

Risposta

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 domande da colloquio

Padroneggia .NET per il tuo prossimo colloquio

Accedi a tutte le domande, flashcards, test tecnici, esercizi di code review e simulatori di colloquio.

Inizia gratis