Middleware & Pipeline Flashcards
6 cards from real ASP.NET Core practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Middleware & Pipeline flashcards as text
What method is used to add middleware to the ASP.NET Core request pipeline?
Answer: app.UseMiddleware()
app.UseMiddleware() registers a custom middleware class in the request pipeline.
Which interface must a custom middleware class implement to be recognized by ASP.NET Core's IMiddlewareFactory?
Answer: IMiddleware
IMiddleware defines the InvokeAsync method that the factory-activated middleware pattern requires.
What is the purpose of the 'next' delegate in ASP.NET Core middleware?
Answer: To call the next middleware in the pipeline
Calling next(context) passes control to the subsequent middleware component in the pipeline.
Which middleware method creates a branch in the pipeline that does NOT rejoin the main pipeline?
Answer: app.Run()
app.Run() adds terminal middleware that never calls next, ending the pipeline branch.
What does app.Map() do in an ASP.NET Core middleware pipeline?
Answer: Branches the pipeline based on a URL path match
app.Map() creates a conditional branch in the pipeline that activates when the request path matches.
In what order should UseRouting() and UseAuthorization() be called in the ASP.NET Core pipeline?
Answer: UseRouting() before UseAuthorization()
UseRouting() must precede UseAuthorization() so that route data is available when authorization policies are evaluated.