Home › Blog › ASP.NET Core Interview Questions (2026): 30 Questions on Middleware, DI and Minimal APIs

ASP.NET Core Interview Questions (2026): 30 Questions on Middleware, DI and Minimal APIs

ASP.NET Core interview questions test the request pipeline (middleware and why its order matters), dependency injection lifetimes, routing with minimal APIs or controllers, configuration and options, and how the app is hosted, secured and tested. Know which .NET you are talking about: Microsoft's official .NET release index, checked November 17, 2026, lists .NET 11 (standard-term support, released November 10, 2026) and .NET 10 (long-term support) as active, both supported until November 14, 2028, while .NET 8 and .NET 9 reached end of support on November 10, 2026.

ASP.NET Core interview questions test the request pipeline (middleware and why its order matters), dependency injection lifetimes, routing with minimal APIs or controllers, configuration and options, and how the app is hosted, secured and tested. Know which .NET you are talking about: Microsoft's official .NET release index, checked November 17, 2026, lists .NET 11 (standard-term support, released November 10, 2026) and .NET 10 (long-term support) as active, both supported until November 14, 2028, while .NET 8 and .NET 9 reached end of support on November 10, 2026.

Below are 30 questions by level, five troubleshooting scenarios and how interviews test this. Runtime and language ground is in .NET interview questions and C# interview questions.

ASP.NET Core interview questions: fundamentals (1–10)

  1. What is ASP.NET Core? Microsoft's cross-platform, open-source framework for web apps and APIs on .NET. It runs on the Kestrel server and hosts minimal APIs, MVC controllers, Razor Pages, Blazor, SignalR and gRPC.
  2. What is middleware? A component in the request pipeline that can handle the request, call the next component and act on the response: app.Use(async (context, next) => { /* before */ await next(context); /* after */ });
  3. Use, Run or Map? Use adds middleware that can call the next one; Run adds terminal middleware; Map branches the pipeline by path.
  4. Why does middleware order matter? Each component only sees what earlier ones let through. A typical order: exception handling, HSTS, HTTPS redirection, static files, routing, CORS, authentication, authorization, then endpoints. Authorization before authentication means every user is anonymous.
  5. What is Kestrel? The built-in, cross-platform web server. It can face the internet directly or run behind a reverse proxy such as IIS, Nginx or YARP, which can add TLS termination, load balancing and other edge features.
  6. What are the DI lifetimes? Singleton (one instance for the app), scoped (one per request), transient (new on every resolve), registered with AddSingleton, AddScoped and AddTransient.
  7. What is a captive dependency? A longer-lived service holding a shorter-lived one, such as a singleton that takes a scoped DbContext, which then lives forever and is shared across requests. Scope validation in the Development environment throws for this at startup.
  8. What does Program.cs look like? var builder = WebApplication.CreateBuilder(args); registers services on builder.Services; var app = builder.Build(); adds middleware and endpoints such as app.MapGet("/ping", () => "pong");; app.Run(); starts it.
  9. How does configuration layer? By default: appsettings.json, then appsettings.{Environment}.json, user secrets in Development, environment variables, then command-line arguments, with later sources overriding earlier ones. Nested keys use :, or __ in environment variables.
  10. How are environments set? With ASPNETCORE_ENVIRONMENT (Development, Staging, Production; Production if unset), checked through app.Environment.IsDevelopment().

Intermediate ASP.NET Core questions (11–20)

  1. IOptions, IOptionsSnapshot or IOptionsMonitor? Bind a section with builder.Services.Configure<SmtpOptions>(builder.Configuration.GetSection("Smtp")). IOptions is a singleton read once; IOptionsSnapshot is scoped and recomputed per request; IOptionsMonitor is a singleton with change notifications. Add ValidateOnStart() to fail fast.
  2. Minimal APIs or controllers? Minimal APIs map handlers directly (MapGet, MapPost, MapGroup) with endpoint filters: less ceremony, good for small services. Controllers add [ApiController] conventions, attribute routing and MVC filters, which suit large APIs. Both share routing, DI and auth.
  3. How does routing work? Endpoint routing matches a request to an endpoint, then the endpoint runs. Templates take constraints such as {id:int}; controllers use attributes such as [Route("api/[controller]")]; route groups share prefixes and policies.
  4. How do model binding and validation work? Values bind from route, query, headers, form or body ([FromBody]). With [ApiController], invalid DataAnnotations produce an automatic 400 with validation problem details. Since .NET 10, minimal APIs get built-in validation after builder.Services.AddValidation().
  5. Filters or middleware? Middleware sees every request but knows nothing about MVC. Filters (authorization, resource, action, exception, result) run inside MVC with access to action arguments and model state; minimal APIs use endpoint filters. Use middleware for cross-cutting HTTP concerns, filters for action-level ones.
  6. Authentication versus authorization? Authentication establishes who the caller is (cookies, JWT bearer, OpenID Connect); authorization decides what they may do with [Authorize], roles or policies built from requirements and handlers, such as .RequireAuthorization("AdminOnly").
  7. What should JWT validation check? Issuer, audience, lifetime and signing key. Tokens are stateless, so revocation is hard; keep access tokens short-lived and use refresh tokens.
  8. How do you configure CORS? Register a policy with AddCors and apply it with UseCors or per endpoint. The CORS specification does not allow a wildcard origin together with credentials, so list origins explicitly.
  9. How do you handle errors globally? UseExceptionHandler with an IExceptionHandler implementation (added in .NET 8) and AddProblemDetails() for RFC-style error bodies. Use the developer exception page only in Development.
  10. Why IHttpClientFactory? new HttpClient() per call can exhaust sockets, and one static client can miss DNS changes. The factory pools handlers and supports named and typed clients; Microsoft.Extensions.Http.Resilience adds retries, timeouts and circuit breakers.

Experienced and senior ASP.NET Core questions (21–30)

  1. How do async and the thread pool interact? await releases the thread during I/O. Blocking on tasks with .Result or .Wait() holds threads and can starve the pool under load, so go async all the way and pass HttpContext.RequestAborted as the cancellation token.
  2. How do you run background work? Subclass BackgroundService (an IHostedService). To use scoped services such as a DbContext, create a scope with IServiceScopeFactory. A Channel<T> gives an in-process queue; work that must survive restarts needs a real queue.
  3. What caching options are built in? IMemoryCache in-process, IDistributedCache backed by Redis or SQL, output caching middleware (added in .NET 7) for whole responses, and HybridCache, one API over memory and distributed caches with stampede protection.
  4. How do you rate-limit? The built-in rate limiting middleware (.NET 7 onward): AddRateLimiter with fixed window, sliding window, token bucket or concurrency limiters, applied with UseRateLimiter and RequireRateLimiting("policy").
  5. How do health checks work? builder.Services.AddHealthChecks() with checks for dependencies, and app.MapHealthChecks("/healthz"). In Kubernetes, separate liveness (the process is up) from readiness (dependencies reachable).
  6. How should you log? Inject ILogger<T> and use message templates, logger.LogInformation("Order {OrderId} paid", id), not string interpolation, so logs stay structured. Add OpenTelemetry for traces and metrics.
  7. How do you generate OpenAPI documents? Since .NET 9, with the built-in Microsoft.AspNetCore.OpenApi package: builder.Services.AddOpenApi() and app.MapOpenApi(). .NET 10 generates OpenAPI 3.1 documents.
  8. How do you integration-test an API? WebApplicationFactory<Program> from Microsoft.AspNetCore.Mvc.Testing runs the app in memory with a real pipeline; swap dependencies with ConfigureTestServices and call it through the provided HttpClient.
  9. How do you improve throughput and startup? Async I/O everywhere, no synchronous body reads, caching, response compression, pooled objects, fewer allocations on hot paths, and Native AOT for minimal APIs when fast startup and small memory matter, accepting its feature limits.
  10. What should you know about .NET versions in 2026? .NET 10 is the LTS most teams target; .NET 11 shipped November 10, 2026 as an STS release; .NET 8 and 9 left support the same day. .NET 10 also added Server-Sent Events support and passkey support in ASP.NET Core Identity.

ASP.NET Core scenario and troubleshooting questions

Requests hang under load while CPU stays low. Classic thread pool starvation from sync-over-async: .Result or .Wait() in a hot path. Confirm with dotnet-counters (thread pool queue length), then make the call chain async.

Startup throws: cannot consume a scoped service from a singleton. A captive dependency. Make the consumer scoped, or have the singleton create a scope with IServiceScopeFactory each time it needs the scoped service.

Every call returns 401 with a valid token. Check that UseAuthentication runs before UseAuthorization, that the token's issuer and audience match validation settings, the clock, and the authentication scheme. The JWT handler's logs usually name the failure.

The browser reports a CORS error but Postman works. CORS is enforced only by browsers. Check that the policy is applied, that UseCors sits in the right place, that the origin matches exactly including scheme and port, and that preflight OPTIONS requests are allowed.

Calls to a partner API fail with socket errors under load. A new HttpClient per request. Move to IHttpClientFactory with a typed client and add timeouts and retries through the resilience handler.

How ASP.NET Core interviews test this

FormatWhat it usually looks likeHow to prepare
Concept Q&AMiddleware order, DI lifetimes, options, auth, minimal APIs versus controllersExplain each with a Program.cs line
Live buildA small CRUD API with validation and an error handler, sometimes with testsBuild one from an empty project in under an hour
Code reviewSpot a captive dependency, .Result or a misplaced middleware callPractice reading Program.cs critically
Senior designAuth, caching, resilience, observability and versioning for a public APITie answers to REST API design

Data access almost always follows; see Entity Framework interview questions.

Where CoPilot Interview fits

CoPilot Interview is an AI interview assistant. Its free AI mock interview builds ASP.NET Core and .NET questions from your résumé and the job description, reads them aloud and scores each spoken answer out of 10, which is a fast way to find the answers above that you know but cannot yet explain cleanly under pressure. The browser demo has 145 practice questions in 10 tracks, scores typed answers out of 10 and needs no signup. The free plan gives 15 minutes a day of live help in sessions of up to 15 minutes, with AI mock interviews included. Paid plans are Standard at $24.99 a month and Pro at $39.99 a month, in the desktop app for Windows 10/11 and macOS 12 or later.

Use it to practice. Online assessments, proctored tests, take-home tasks with rules and AI-led rounds forbid outside help, so prepare for those instead of bringing a tool. For any live interview, follow your employer's rules.

Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly.

Frequently asked questions

What are the most common ASP.NET Core interview questions?

Middleware and its order, DI lifetimes (singleton, scoped, transient), minimal APIs versus controllers, the options pattern, authentication versus authorization, filters, IHttpClientFactory and async best practices.

What is the difference between AddSingleton, AddScoped and AddTransient?

AddSingleton creates one instance for the app's lifetime, AddScoped one per request, and AddTransient a new instance every time the service is resolved.

Should I use minimal APIs or controllers?

Minimal APIs for small, focused services and new projects that value less ceremony; controllers for large APIs that benefit from conventions and MVC filters. Interviewers mainly want you to justify the choice.

Which .NET version should I know for interviews?

.NET 10, the current LTS. As of November 17, 2026, .NET 11 has also shipped (November 10, 2026), and .NET 8 and 9 are out of support.

What is middleware in ASP.NET Core?

A component in the request pipeline that can inspect or change the request, call the next component, and inspect or change the response on the way back.

Practice this interview before the real one

The AI mock interview builds questions from your resume and the job description, reads them aloud and scores each spoken answer out of 10. Included on the free plan.

Start a mock interview