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 is the difference between app.Use() and app.Run() middleware registration?
Answer: Use() can call next middleware; Run() is terminal and cannot
app.Use() receives next delegate and can pass control forward, while app.Run() is a terminal middleware with no next.
Which middleware enables Cross-Origin Resource Sharing in ASP.NET Core?
Answer: UseCors()
UseCors() applies CORS policies to responses, and must be called before UseRouting or after UseRouting per policy.
What class is used to write custom convention-based middleware in ASP.NET Core?
Answer: A plain class with an Invoke or InvokeAsync method
ASP.NET Core discovers convention-based middleware as any class with a public Invoke or InvokeAsync method taking HttpContext.
In which environment is UseDeveloperExceptionPage() typically called?
Answer: Development
UseDeveloperExceptionPage() shows detailed error info and should only be used in Development to avoid leaking sensitive data.
What does the RequestDelegate type represent in ASP.NET Core middleware?
Answer: A function that processes an HTTP request
RequestDelegate is defined as Func and represents an async function that handles an HTTP request.
Which middleware logs HTTP request and response information in ASP.NET Core?
Answer: UseHttpLogging()
UseHttpLogging() (introduced in .NET 6) logs structured HTTP request and response data via the logging infrastructure.