Skip to main content
InterviewHubPRO
Section Overview
Q1

Question 1 of 50

Part 1: Request Pipeline, Dependency Injection & Web APIs (1 - 10)

2%
ASP.NET Core & Web API (50 Qs)•Part 1: Request Pipeline, Dependency Injection & Web APIs (1 - 10)

Walk through the ASP.NET Core Request Middleware Pipeline.

senior LevelMost AskedCode ExampleDependency InjectionPipesCI/CD & DevOps

In Simple Words: The HTTP request pipeline is a sequence of delegate functions (RequestDelegate) arranged in bidirectional order:

  1. Request arrives at Kestrel web server.
  2. Passes through middleware components in registered order: ExceptionHandler -> Hsts -> HttpsRedirection -> StaticFiles -> Routing -> Cors -> Authentication -> Authorization -> Custom Middleware -> Endpoints.
  3. An endpoint handler executes (Controller action or Minimal API route).
  4. Response traverses back in reverse order through the same middleware components.
csharp
var app = builder.Build();

// Bidirectional Middleware Pipeline:
app.UseExceptionHandler("/error");
app.UseHttpsRedirection();
app.UseAuthentication(); // 1. Who are you?
app.UseAuthorization();  // 2. Are you allowed?

app.MapGet("/api/health", () => Results.Ok(new { status = "healthy", timestamp = DateTime.UtcNow }));

app.Run();