Middleware & Request 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 & Request Pipeline flashcards as text
Which property of HttpContext gives access to the response body stream?
Answer: HttpContext.Response.Body
HttpContext.Response.Body is the stream to which middleware writes the HTTP response body.
What does UseHsts() middleware do?
Answer: Adds HTTP Strict Transport Security headers
UseHsts() adds the Strict-Transport-Security response header, instructing browsers to only connect via HTTPS.
What is the purpose of UseResponseCompression() middleware?
Answer: Compresses HTTP responses to reduce bandwidth
UseResponseCompression() compresses HTTP responses using Gzip or Brotli to reduce response size and improve performance.
Which interface provides access to middleware-specific features from HttpContext?
Answer: IFeatureCollection
HttpContext.Features returns an IFeatureCollection that provides access to server and middleware feature interfaces.
What happens when middleware adds to HttpContext.Items?
Answer: Data is shared only for the lifetime of the current request
HttpContext.Items is a dictionary scoped to the current request, allowing middleware and handlers to share data within a single request.
Which method enables response buffering to allow middleware to modify the response body?
Answer: response.EnableBuffering()
response.EnableBuffering() replaces the response stream with a seekable buffer, allowing middleware to read and modify the response body.