.NET Interview Questions — Practice With Real Questions

Reviewed by Mark Dickie · Last updated

13 questions on this page you can answer and see marked on the spot. Go to the first one

The .NET platform is a cross-platform development ecosystem from Microsoft that includes the Common Language Runtime, the C# language, the base class library, and frameworks like ASP.NET Core and EF Core. For interviews you should know how the CLR executes managed code (JIT compilation, garbage collection, assembly loading), the core C# language features (async/await, LINQ, generics, delegates, pattern matching), and the major application frameworks built on top of the runtime.

Most .NET interview rounds split into language fundamentals, runtime behavior, and framework-specific questions. A strong candidate can explain value types vs reference types, how garbage collection generations work, what async/await actually does at the state machine level, and the request pipeline in ASP.NET Core. Below is a quick map of what each area tends to cover.

Interview areaWhat comes up
C# languageValue vs reference types, ref/out/in, generics, delegates and events, pattern matching, records
CLR internalsJIT vs AOT compilation, GC generations and large object heap, assembly resolution, AppDomains (legacy) vs single-file
ASP.NET CoreMiddleware pipeline, dependency injection containers, routing, minimal APIs, configuration sources
EF CoreChange tracking, query execution, lazy vs eager loading, migrations, concurrency tokens
ConcurrencyTask, async/await, CancellationToken, Channel<T>, locking, Interlocked

What does a .NET interview typically test?

  1. Type system fundamentals: stack vs heap allocation, boxing, nullable reference types, and how generic constraints affect compilation.
  2. Runtime mechanics: how the JIT compiles IL to native code, when GC triggers a collection, and what the large object heap does to performance.
  3. Async programming: the state machine the compiler generates for async/await, synchronization context, and common deadlock patterns with .Result.
  4. ASP.NET Core pipeline: how middleware order matters, where DI scopes live, and how endpoint routing resolves to a handler.
  5. Data access with EF Core: how DbContext tracks entities, when a query is executed, and how to handle concurrency conflicts.

How should you prepare for a .NET interview?

Focus on understanding over memorization. If you can explain why the runtime behaves a certain way, you can answer the follow-up questions that interviewers use to separate surface-level knowledge from real understanding. Write small console apps to trigger GC collections, inspect IL with tools like ILSpy, and trace an HTTP request through the ASP.NET Core middleware pipeline. The quiz below covers a mix of language, runtime, and framework questions so you can find gaps before the real thing.

Key facts

  • Tarmac has 233 .NET interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
  • Tarmac tracked 747 job postings asking for .NET in November 2026.
  • Roles asking for .NET advertise a median base salary of £70,000, across 302 job postings as of November 2026.
  • Tarmac last reviewed these .NET interview questions on 20 October 2026.

At a glance

Questions25 shown · 233 in the bank
Difficulty1–5 of 5
FormatsTrue / false, Multiple choice, Find the bug, Ordering, Short answer, Fill in the blank, Multiple answer, Code output, Flashcard

What you'll review

  1. minimal apis
  2. middleware pipeline
  3. routing in aspnet core
  4. mvc controllers and views

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

In ASP.NET Core, Minimal APIs allow you to define HTTP endpoints using lambda expressions or method delegates passed to extension methods like MapGet and MapPost, without requiring a controller class.#

Options

Show answer

True. ASP.NET Core Minimal APIs let you define endpoints by passing lambda expressions or method delegates to extension methods such as MapGet and MapPost on IEndpointRouteBuilder, without requiring a controller class.

Why:

Minimal APIs, introduced in .NET 6, let you register endpoints directly on IEndpointRouteBuilder via methods like MapGet and MapPost, passing a delegate as the handler. No controller class is needed, unlike the traditional MVC/web-api controller pattern.

In ASP.NET Core Minimal APIs, route parameters in the URL pattern (e.g. {id} in MapGet("/items/{id}", ...)) are automatically bound to handler method parameters with matching names by default.#

Options

Show answer

True. In ASP.NET Core Minimal APIs, route parameters declared in the URL pattern such as {id} are automatically bound to handler parameters with matching names by default, with no explicit attribute required.

Why:

Minimal APIs use model binding conventions: a route parameter like {id} is automatically bound to a handler parameter named id (case-insensitive) without explicit attributes, as long as the name matches.

In ASP.NET Core's minimal hosting model (Program.cs), which call registers a middleware component on the request pipeline that receives the next delegate and decides whether to invoke it?#

Options

Show answer

The app.Use(async (context, next) => { ... }) call registers a middleware component in ASP.NET Core. Each component receives the next delegate and decides whether to invoke it, and calls are executed in the order they are registered. Service registrations such as AddControllers and configuration calls such as AddJsonFile do not add pipeline middleware.

Why:

Middleware components are added to the pipeline on the IApplicationBuilder (app) with a Use-style call, and the Use overload that takes (context, next) is the direct form: the component runs its logic, then decides whether to call next to pass control down the pipeline. The other three calls do not touch the request pipeline. Registering controllers and a scoped service adds entries to the IServiceCollection for dependency injection, and adding a JSON file configures the IConfigurationBuilder. Because registration order equals execution order, the Use call is the one that determines where a component sits in the pipeline.

What does calling app.Run(context => { ... }) do in an ASP.NET Core middleware pipeline?#

Options

Show answer

app.Run adds a terminal middleware delegate that takes only the HttpContext and has no next parameter, so it ends the pipeline and prevents any later middleware from executing. Use app.Use when you need to call next and continue the chain.

Why:

app.Run adds a terminal middleware delegate — it receives only the HttpContext (no next parameter) and therefore cannot invoke the next middleware. Execution ends at that delegate, so anything registered after it never runs. app.Use is the method that provides a next delegate for chaining. Map branches the pipeline, and background services are registered via AddHostedService, not app.Run.

ASP.NET Core middleware components form a pipeline through which every HTTP request passes. The pipeline is commonly described as having two phases per request. In what order does a single middleware component process a request relative to the components registered before and after it?#

Options

Show answer

Middleware follows an onion/stack model: the code before await next() runs in registration order (top-to-bottom) on the way in, and the code after await next() runs in reverse registration order (bottom-to-top) on the way out. This bidirectional flow is why ordering matters for cross-cutting concerns like logging and exception handling.

Why:

The middleware pipeline behaves like a stack (onion model). On the way in, each component's code before await next() executes in the order the components were registered (top-to-bottom). On the way out, after next() returns, each component's remaining code executes in the reverse order (bottom-to-top) as the stack unwinds.

The following ASP.NET Core controller compiles without errors, but a GET request to /api/products/42 returns 0 instead of 42. Find the line containing the bug.#

[ApiController]
[Route("api/products")]
public class ProductsController : ControllerBase
{
    [HttpGet("{id}")]
    public IActionResult GetById(int productId)
    {
        return Ok(productId);
    }
}
Show answer

The bug is on line 6.

Why:

The route template on line 5 defines a parameter named {id}, but the action method parameter on line 6 is named productId. ASP.NET Core binds route values to action parameters by name, so the route value id is never matched to productId, which defaults to 0. Renaming the parameter to int id (or adding [FromRoute(Name = "id")]) fixes the binding.

A developer expects GET /api/products to work, but requests to that URL return 404. Which option identifies the bug?#

[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
    [HttpGet("list")]
    public IActionResult GetAll()
    {
        return Ok();
    }
}

Options

Show answer

Line 5: [HttpGet("list")] adds a list segment, so the action is routed to api/products/list and GET /api/products matches no endpoint.

Why:

The [controller] token in the class-level [Route] is valid and is replaced with Products (routing is case-insensitive), so the base template is api/products. The action's [HttpGet("list")] template is appended to that base, producing api/products/list. No endpoint matches GET /api/products, so the framework returns 404. Removing the list segment (using a bare [HttpGet]) makes the action match api/products. The other options are wrong: [ApiController] works with attribute routing, [controller] is a supported token, and action method names do not affect attribute routing.

Arrange these ASP.NET Core MVC filter types in the order they run in the filter pipeline, from first to last. (Exception filters are not included: they handle unhandled exceptions from the action stage and do not run in the result stage, so they have no single fixed position in this sequence.)#

Put these in order

Show answer

In ASP.NET Core MVC, the filter pipeline runs authorization filters first, then resource filters, then action filters, and finally result filters. Authorization filters gate access before anything else runs, resource filters wrap model binding and the rest of the pipeline, action filters wrap the action method, and result filters wrap execution of the action result.

Why:

The ASP.NET Core MVC pipeline runs these four filter types in a fixed sequence. Authorization filters run first to decide whether the request may proceed. Resource filters come next and wrap model binding and the remainder of the pipeline. Action filters wrap execution of the action method itself. Result filters run around execution of the action result, such as view rendering. Exception filters are left out of the ordering because they handle only unhandled exceptions from controller creation, model binding, action filters and action methods; they do not handle exceptions from result filters or result execution, so they are not a step in this linear sequence.

In ASP.NET Core Minimal APIs, what method do you call on the WebApplication instance to register an HTTP GET endpoint at the path /products? Write the exact method name (no parentheses or arguments).#

Show answer

MapGet

Why:

In Minimal APIs, endpoints are registered by calling extension methods like MapGet, MapPost, MapPut, and MapDelete on the WebApplication (or IEndpointRouteBuilder) instance. To handle GET requests at /products you call app.MapGet("/products", handler).

Order the following stages of the ASP.NET Core MVC request-processing pipeline as they occur when handling an incoming HTTP request that results in a rendered view (from first to last).#

Put these in order

Show answer

The correct order is: Routing → Model Binding → Action Method Execution → Action Result Execution → View Rendering. ASP.NET Core MVC first matches the request to an action via routing, binds request data to parameters, executes the action method (which returns an IActionResult), then executes that result, and finally renders the Razor view into the HTTP response.

Why:

ASP.NET Core MVC processes a request in a fixed sequence: routing first selects the action, then model binding populates parameters, the action method runs and produces an IActionResult, the result executes (which for a ViewResult locates the view), and finally the Razor view is rendered into the response body.

In the ASP.NET Core MVC filter pipeline, each filter type has a defined position. Order these filter types by when their 'before' (OnXxxExecuting) phase runs during request processing, from earliest to latest.#

Put these in order

Show answer

The correct order is: Authorization Filters → Resource Filters → Action Filters → Result Filters. In the ASP.NET Core MVC filter pipeline, authorization filters run first and can short-circuit the request, resource filters wrap the rest of the pipeline, action filters run immediately before and after the action method, and result filters run immediately before and after the action result executes.

Why:

Per the official ASP.NET Core filter pipeline, the 'before' phases execute in this order: authorization filters run first (short-circuiting the rest if denied), then resource filters (wrapping most of the pipeline), then action filters (immediately before the action method), and finally result filters (immediately before the action result executes). Exception filters are triggered only when an unhandled exception occurs and are not part of this sequential 'before' ordering.

In an ASP.NET Core minimal-hosted app (Program.cs), conventional routing for MVC controllers is typically registered by calling _____ with a route name and a pattern such as "{controller=Home}/{action=Index}/{id?}".#

Show answer

In an ASP.NET Core minimal-hosted app (Program.cs), conventional routing for MVC controllers is typically registered by calling **MapControllerRoute** with a route name and a pattern such as "{controller=Home}/{action=Index}/{id?}".

Why:

MapControllerRoute is an extension method on IEndpointRouteBuilder, typically called on app (the WebApplication) inside the top-level statements of Program.cs. It accepts a route name and a route pattern, making it the standard way to register a named conventional route. By contrast, MapDefaultControllerRoute takes no arguments and uses a hard-coded default pattern, while MapControllers is used for attribute-routed controllers only.

To enable attribute routing in ASP.NET Core, you apply the verb-agnostic _____ attribute (one not tied to any specific HTTP verb such as GET or POST) directly on a controller class or an individual action method to specify its URL template, e.g. [_____("products/{id}")].#

Show answer

To enable attribute routing in ASP.NET Core, you apply the verb-agnostic **Route** attribute (one not tied to any specific HTTP verb such as GET or POST) directly on a controller class or an individual action method to specify its URL template, e.g. [**Route**("products/{id}")].

Why:

The [Route] attribute is the verb-agnostic attribute-routing marker in ASP.NET Core. It can be placed on a controller class to set a base template or on an action method to set or combine that action's template. The HTTP-verb attributes such as [HttpGet] and [HttpPost] also accept templates, but they are tied to a specific verb and cannot be applied to a controller class, so the prompt's verb-agnostic, class-or-method wording points to Route.

In the ASP.NET Core route template "{id:int?}", the int portion is called a route _____ — it restricts the id segment to integer values only, while the trailing ? marks the parameter as optional.#

Show answer

In the ASP.NET Core route template "{id:int?}", the int portion is called a route constraint — it restricts the id segment to integer values only, while the trailing ? marks the parameter as optional.

Why:

The colon syntax inside a route parameter ({param:constraint}) applies a route constraint. int is a built-in constraint that only matches the segment when it can be parsed as an integer. Constraints are evaluated during URL matching; if the segment does not satisfy the constraint, that route is not selected.

In ASP.NET Core Minimal APIs, a custom endpoint filter registered via AddEndpointFilter<TFilter> must implement a specific interface. Name the interface and the single instance method it requires, including the method's exact return type.#

Show answer

The interface is IEndpointFilter. It requires the method InvokeAsync, which has the return type ValueTask<object?>.

Why:

Every Minimal API endpoint filter implements IEndpointFilter, which defines one method: ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next). The ValueTask<object?> return type allows the filter to either short-circuit by returning a result directly or call next to continue the pipeline. Knowing the return type is important because it differs from the MVC action-filter Task<IActionResult> pattern.

In ASP.NET Core Minimal APIs, both Results and TypedResults are factory classes that produce IResult response objects. What is the primary advantage of using TypedResults over Results when declaring a route handler's return type? Mention both the compile-time benefit and the documentation benefit.#

Show answer

TypedResults returns concrete generic types such as Ok<T> instead of the non-generic IResult, which gives compile-time type safety for the response payload and allows the OpenAPI/Swagger document to automatically infer the correct response body schema at compile time without extra configuration.

Why:

Results.Ok(...) returns IResult, erasing the payload type at compile time, so the compiler cannot verify that the handler returns the declared shape and OpenAPI cannot infer the response body schema without manual annotations. TypedResults.Ok<T>(value) returns Ok<T>, a concrete generic IResult implementation, giving compile-time type checking on the response payload and enabling automatic OpenAPI response schema generation directly from the handler's return type signature.

Which of the following statements about the ASP.NET Core middleware pipeline are true?#

Options

Pick every one that applies.

Show answer

app.Run(), app.Use(), and app.Map() each behave as described in the correct choices: app.Run() adds terminal middleware with no next component, app.Use() middleware may choose whether to call the next component, and app.Map() sends path-prefix matches into a branch that does not rejoin the parent pipeline. The first-registered middleware sees the response last, not first.

Why:

app.Run() registers terminal middleware that receives no next component, so nothing after it in that pipeline runs; the statement that it never calls the next component is true. app.Use() middleware receives the next component and can call it to continue the pipeline, or omit the call to short-circuit the request; that statement is true. app.Map("/path", ...) branches requests whose path starts with the prefix, and those matched requests run the branch rather than continuing into the parent pipeline's later middleware; that statement is true. Request processing follows registration order, but the response unwinds in reverse, so the first-registered middleware is the last to observe the response. The statement claiming the first-registered middleware sees the response first is therefore false.

An ASP.NET Core MVC app defines the controller below. A client sends the request:#

[Route("api/[controller]")]
public class SearchController : Controller
{
    [HttpGet("{query}")]
    public IActionResult Search(string query) => Content($"S:{query}");

    [HttpGet("{id:int}")]
    public IActionResult GetById(int id) => Content($"I:{id}");

    [HttpGet("{query:alpha}/{page:int}")]
    public IActionResult Paged(string query, int page) => Content($"P:{query}:{page}");
}
Show answer
P:hello:2
Why:

The request path /api/search/hello/2 has two route segments after the controller prefix (hello and 2). The Search action template {query} expects one segment and the GetById action template {id:int} also expects one segment, so neither can match. The Paged action template {query:alpha}/{page:int} matches two segments: "hello" satisfies the :alpha constraint (letters only) and "2" satisfies the :int constraint. Content("P:hello:2") returns that string as the response body with content type text/plain.

In ASP.NET Core Minimal APIs, what is the key difference between returning TypedResults.Ok(product) and Results.Ok(product) from an endpoint handler, and which should you prefer for compile-time type safety and OpenAPI schema accuracy?#

Show answer

Prefer TypedResults. TypedResults.Ok(product) returns the concrete class Ok<Product> (namespace Microsoft.AspNetCore.Http.HttpResults), so the payload type appears in the handler's declared return type. Endpoint metadata comes from the IEndpointMetadataProvider interface that this result class implements, so the 200 response schema is inferred without extra attributes. Results.Ok(product) returns the IResult interface, which hides the payload type from the signature and from metadata inference, so you must add .Produces<Product>() or [ProducesResponseType] for the schema to appear. The compiler checks payload types only when a handler returns a Results<...> union, which accepts only its listed result types. TypedResults results are also easier to unit test, because you can assert on the returned object's Value and StatusCode without running the HTTP pipeline.

Why:

TypedResults.Ok(product) and Results.Ok(product) both produce an HTTP 200 with the serialized product at runtime. The difference is the static type they expose. TypedResults factory methods return concrete result classes such as Ok<Product>, which implement IResult and IEndpointMetadataProvider, so the framework reads the response type from the declared return type and records it for OpenAPI with no extra annotations. Results factory methods return the IResult interface, so the payload type is not visible in the signature or to metadata inference, and you must declare it with .Produces<T>() or [ProducesResponseType]. Compile-time checking of returned results against a declared set happens when the handler returns a Results<...> union, which rejects result types not listed. Because TypedResults results expose their Value and StatusCode directly, they are also easier to unit test. The recommendation to prefer TypedResults therefore holds for type safety, schema accuracy, and testability.

How are endpoint filters ordered in an ASP.NET Core Minimal API pipeline, how are they registered, and what does that ordering mean for when a filter's pre- and post-handler logic runs relative to other filters and the handler itself?#

Show answer

Endpoint filters execute in registration order: the first filter added runs first and is the outermost wrapper, so the pipeline is a nested Russian-doll structure. Filters added to a route group (via MapGroup(...).AddEndpointFilter<TFilter>()) run before the filters added to an individual endpoint. Each filter calls next(context) to invoke the next filter, or the terminal handler if it is last. Control unwinds in reverse on the return path, so the first-registered filter sees the request first and the response last. Register them with .AddEndpointFilter<TFilter>() on the RouteHandlerBuilder returned by MapGet, MapPost, and similar methods, or chain multiple .AddEndpointFilter calls.

Why:

Minimal API endpoint filters form a nested pipeline, similar to middleware. Filters run in the order they are registered, so the first one wraps all later filters and the handler. Filters added to a route group are placed ahead of the filters added to the individual endpoint, so group filters are the outermost wrappers for that endpoint. Each filter calls next(context) to pass control inward; once the terminal handler returns, control unwinds in reverse, so the last filter's post-handler code runs first and the first-registered filter's post-handler code runs last. Because of this, the earliest-registered filter (or a group-level filter) has the broadest scope and suits cross-cutting concerns such as timing or global exception handling. Filters are attached with the AddEndpointFilter<TFilter>() extension on RouteHandlerBuilder or RouteGroupBuilder.

What role does RequestDelegateFactory play in Minimal APIs, and how does the source-generated variant (Microsoft.AspNetCore.Http.RequestDelegateGenerator) change the runtime behavior and enable Native AOT publishing?#

Show answer

RequestDelegateFactory (RDF) is the runtime component that transforms a Minimal API route handler lambda into a RequestDelegate. It inspects the delegate's parameters, binds each to the appropriate source (route, query, header, body via [FromBody], services via [FromServices]), injects HttpContext/HttpRequest/CancellationToken when present, and synthesizes response-writing logic — all via runtime reflection and dynamic IL emission. The separate source generator Microsoft.AspNetCore.Http.RequestDelegateGenerator (distinct from RDF and from the Microsoft.AspNetCore.OpenApi package) performs the same transformation at compile time, emitting static C# into the user's assembly instead of using runtime reflection. This eliminates reflection over handler signatures, makes the code trim-safe, and is what enables Native AOT publishing of Minimal API apps.

Why:

RequestDelegateFactory is the runtime bridge between a developer-authored lambda and the RequestDelegate that ASP.NET Core's routing infrastructure invokes. It reads the lambda's parameter list, infers each parameter's binding source, generates code to populate parameters from HttpContext, and generates response serialization — all at runtime via reflection and dynamic IL. RequestDelegateGenerator is a separate component (packaged in Microsoft.AspNetCore.Http.RequestDelegateGenerator, not Microsoft.AspNetCore.OpenApi) that performs the same transformation at compile time, emitting static C# into the assembly. This eliminates runtime reflection, makes the code trim-safe, and is required for Native AOT publishing.

In an ASP.NET Core 8 minimal-host application, consider the middleware ordering rules enforced or recommended by the framework. Which of the following statements are correct? (Select all that apply.)#

Options

Pick every one that applies.

Show answer

Four statements are correct for ASP.NET Core 8 middleware ordering: routing before authorization exposes endpoint metadata, authentication before authorization populates the user for policy checks, the minimal host adds routing automatically, and early exception handling wraps later middleware. Static files do not need to come after routing.

Why:

Authorization middleware reads endpoint metadata (such as [Authorize] and policy attributes) from the matched endpoint, so routing must have run first; placing routing before authorization makes that metadata available. Authentication populates HttpContext.User, so if authentication runs after authorization, policies are evaluated against an unpopulated user. In a WebApplication the host adds routing automatically at the start of the pipeline, so an explicit call is not needed. Registering exception handling early lets its try/catch surround later middleware. The statement that static files must come after routing is false: static file handling does not depend on endpoint routing and is conventionally registered early, before routing.

You are building a custom middleware pipeline in ASP.NET Core 8 and are considering the branching extensions Map, MapWhen, and UseWhen, as well as the Run extension. Which of the following statements about these APIs are correct? (Select all that apply.)#

Options

Pick every one that applies.

Show answer

MapWhen branches are terminal and do not rejoin the main pipeline, UseWhen branches rejoin the main pipeline after their middleware executes, and Map moves the matched path prefix from Request.Path to Request.PathBase. A Map branch does not rejoin the main pipeline, and Run registers a terminal delegate that does not call next.

Why:

Map creates a branch that does NOT rejoin the main pipeline; it is terminal once entered (the claim that a Map branch rejoins the main pipeline is false). MapWhen similarly creates a terminal branch that does not call back into the main pipeline (the claim that MapWhen branches are terminal is true). UseWhen, by contrast, creates a branch that rejoins the main pipeline — it wraps the remaining pipeline so that after the branch middleware completes, execution continues with the next middleware in the main pipeline (the claim that UseWhen branches rejoin the main pipeline is true). Run registers a terminal middleware delegate that does not receive or call a next delegate (the claim that Run automatically calls await next() is false). When Map matches a path prefix such as "/api", it prepends that segment to Request.PathBase and removes it from Request.Path so branch middleware sees the remainder (the claim about Map splitting Request.Path and Request.PathBase is true).

An ASP.NET Core MVC app has the controller below. A browser sends a single request: GET /Checkout/Start. TempData is backed by the default cookie-based provider. Trace the TempData lifecycle across the two redirects and determine the exact string written to the HTTP response body by the Confirm action's Content result.#

using Microsoft.AspNetCore.Mvc;

public class CheckoutController : Controller
{
    public IActionResult Start()
    {
        TempData["Step"] = "Start";
        TempData["Count"] = 1;
        return RedirectToAction("Process");
    }

    public IActionResult Process()
    {
        var step = TempData["Step"]?.ToString() ?? "None";
        var count = TempData["Count"]?.ToString() ?? "0";
        TempData["Step"] = "Process";
        TempData.Keep("Count");
        return RedirectToAction("Confirm");
    }

    public IActionResult Confirm()
    {
        var step = TempData["Step"]?.ToString() ?? "None";
        var count = TempData["Count"]?.ToString() ?? "0";
        return Content($"Step={step}, Count={count}");
    }
}
Show answer
Step=Process, Count=1
Why:

In Start, TempData["Step"]="Start" and TempData["Count"]=1 are both set (unmarked for deletion) and survive the redirect. In Process, reading TempData["Step"] returns "Start" and marks Step for deletion; reading TempData["Count"] returns "1" and marks Count for deletion. Then TempData["Step"]="Process" reassigns Step, which removes it from the deletion set. TempData.Keep("Count") also removes Count from the deletion set. Both values survive the redirect to Confirm. In Confirm, TempData["Step"] reads "Process" and TempData["Count"] reads "1", so Content writes exactly Step=Process, Count=1.

In ASP.NET Core, when middleware components are registered via app.Use(...) in order A, then B, then C, any code that A places after await next(context) executes only after both B's and C's entire invocation (including their own post-next code) has completed — i.e., the response-side processing follows last-in-first-out (LIFO) order.#

Options

Show answer

True. The ASP.NET Core middleware pipeline is a nested delegate chain: each middleware wraps the next, so the first-registered component runs first on the request path and last on the response path. Code placed after await next(context) in middleware A executes only after every downstream middleware (B, C, …) has fully completed, yielding LIFO order on the response side.

Why:

The middleware pipeline is built as a chain of nested delegates: each Use call receives the next delegate and wraps it. When A calls await next(context), control flows to B; when B calls await next(context), control flows to C. C completes first, then B's post-next code runs, then A's post-next code runs. The first-registered middleware is the first to see the request and the last to see the response, producing strict LIFO ordering on the response path.

Related interview questions

Job market

See dotnet salaries and hiring demand from live job postings.

The other 208 questions

This page shows 25 and marks what you pick. That's as far as a page can go. A free account opens the other 208 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.