📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Phase 9 — ASP.NET Core

How ASP.NET Core on .NET 10 hosts, routes and handles requests: Kestrel and hosting, the middleware pipeline, Minimal APIs and MVC, configuration and options, logging, OpenAPI, and real-time and background services.

  1. What is ASP.NET Core, and how does an HTTP request flow through it end to end? Walk me from the socket to the response: Kestrel, the middleware pipeline, routing, the endpoint and back.

    What ASP.NET Core is and the end-to-end request path: Kestrel accepting the connection, HttpContext creation, the middleware pipeline, endpoint routing (UseRouting and endpoint execution), the endpoint delegate and the response flowing back out.

    Beginner Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  2. What are the hosting models for ASP.NET Core? Compare Kestrel on its own, IIS in-process and out-of-process through the ASP.NET Core Module, and HTTP.sys, and tell me when you would choose each.

    ASP.NET Core hosting models: Kestrel as an edge server, Kestrel behind a reverse proxy, IIS in-process and out-of-process via the ASP.NET Core Module (ANCM), and HTTP.sys, with when to choose each.

    Junior Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  3. What is the Generic Host, and what does WebApplicationBuilder set up for you? Explain what happens when you call Build() and Run(): configuration, logging, dependency injection, IHostApplicationLifetime events and graceful shutdown.

    The .NET Generic Host and WebApplicationBuilder: default configuration sources, logging providers and DI registrations created by CreateBuilder, what Build() and Run() do, IHostedService start order, IHostApplicationLifetime events and how graceful shutdown works with HostOptions.ShutdownTimeout.

    Intermediate Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  4. What is middleware in ASP.NET Core? Explain Use, Run and Map (and UseWhen/MapWhen), why the order you register middleware matters, and how you write custom middleware, convention-based versus IMiddleware.

    ASP.NET Core middleware: RequestDelegate, Use/Run/Map/MapWhen/UseWhen, the recommended built-in order, short-circuiting, and writing custom middleware as a convention-based class (singleton, scoped services via InvokeAsync parameters) or as IMiddleware (resolved from DI per request).

    Junior Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  5. Your API has middleware order problems: [Authorize] endpoints are reachable without a token, browser calls fail with CORS errors even though CORS is configured, the exception handler returns a blank 500 instead of ProblemDetails, and static files are served before authentication. How do you diagnose and fix these?

    Diagnosing middleware ordering bugs in ASP.NET Core: authorisation before routing or missing, CORS registered after authentication or without a policy on the endpoint, UseExceptionHandler registered late or a started response, static files before authentication, and the tools to find them (logging, endpoint inspection, WebApplicationFactory tests).

    Mid-Level Debugging ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  6. How does endpoint routing work in ASP.NET Core? Explain route templates and constraints, how the router chooses between matching routes (precedence), how link generation works, and what endpoint metadata is used for.

    Endpoint routing in ASP.NET Core: route templates, parameters, constraints and catch-alls, the matcher and route precedence rules, ambiguous matches, link generation with LinkGenerator and named routes, and endpoint metadata consumed by authorisation, CORS, rate limiting and OpenAPI.

    Intermediate Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  7. Minimal APIs or controllers? Compare them on features, filters, model binding, validation, testability and performance in .NET 10, and tell me how you would choose for a new service.

    Minimal APIs versus MVC controllers in .NET 10: programming model, binding and validation differences (built-in Minimal API validation in .NET 10), endpoint filters versus MVC filters, conventions, OpenAPI, Native AOT support, testability and how to choose.

    Junior Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  8. Your Minimal API has grown to 80 endpoints in one Program.cs. Show me how you would organise it: route groups, one extension method per feature, TypedResults with Results<...> return types, shared filters and metadata, and how you would test it with WebApplicationFactory.

    Coding question on structuring a large Minimal API in .NET 10: feature folders with IEndpointRouteBuilder extension methods, MapGroup with shared prefixes, auth, tags and filters, static handler methods returning Results<T1, T2> via TypedResults, unit-testing handlers directly and integration-testing with WebApplicationFactory.

    Mid-Level Coding ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. Explain MVC in ASP.NET Core: controllers, actions and action results, and what the [ApiController] attribute changes. Then compare Razor Pages with MVC controllers plus Razor Views, and tell me when each fits.

    ASP.NET Core MVC: controllers, actions, IActionResult and ActionResult<T>, the [ApiController] behaviours (attribute routing requirement, automatic 400 ValidationProblemDetails, binding source inference, ProblemDetails for error codes), and Razor Pages (page model, handler methods) versus MVC with Razor Views.

    Intermediate Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups
  10. Every time you deploy your ASP.NET Core API to Kubernetes (or Azure Container Apps), clients see a burst of 502 and 503 errors for about 30 seconds, then everything recovers. How do you diagnose it, and how do you fix it with graceful shutdown, HostOptions.ShutdownTimeout, readiness probes and connection draining?

    Diagnosing 502/503 errors during rolling deployments of ASP.NET Core on Kubernetes or Container Apps: the SIGTERM and endpoint-removal race, preStop delays, readiness versus liveness probes, HostOptions.ShutdownTimeout versus terminationGracePeriodSeconds, Kestrel connection draining, keep-alive timeouts versus load balancer idle timeouts, and start-up readiness.

    Senior Debugging ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  11. Tell me about Kestrel limits and tuning. What do MaxConcurrentConnections, MaxRequestBodySize, the header and timeout limits, and the HTTP/2 and HTTP/3 settings control, what are the defaults, and in practice what actually limits the throughput of an ASP.NET Core service?

    Kestrel server limits and tuning in .NET 10: connection limits, request body size and per-endpoint overrides, header limits, KeepAliveTimeout, RequestHeadersTimeout and MinRequestBodyDataRate, HTTP/2 stream and window settings, enabling HTTP/3 with QUIC, and how to find the real throughput bottleneck (ThreadPool, CPU, allocations, downstream I/O) with measurement.

    Senior Theory ASP.NET Core Fundamentals Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  12. How does model binding work in ASP.NET Core? Explain the binding sources ([FromRoute], [FromQuery], [FromBody], [FromHeader], [FromForm], [FromServices], [AsParameters]) and the rules each framework uses to infer the source when you don't specify one, in controllers versus Minimal APIs.

    Model binding in ASP.NET Core: the binding source attributes, how controllers with [ApiController] and Minimal APIs infer sources for simple types, complex types, services and special types, the one-body rule, [AsParameters] parameter objects, and what happens when binding fails.

    Junior Theory Request Handling Β· πŸ”— 2 follow-ups
  13. How do you validate requests in ASP.NET Core? Cover DataAnnotations, the automatic 400 from [ApiController], FluentValidation, and the built-in Minimal API validation added in .NET 10. Where do business rules belong compared with input validation?

    Request validation in ASP.NET Core .NET 10: DataAnnotations and IValidatableObject, ModelState and the [ApiController] automatic ValidationProblemDetails 400, FluentValidation (manual or via filters), AddValidation() for Minimal APIs, and the split between input validation and domain/business rules.

    Intermediate Theory Request Handling Β· πŸ”— 2 follow-ups
  14. What are MVC filters in ASP.NET Core? Explain the authorisation, resource, action, exception and result filters, the order they run in, how scope (global, controller, action) and the Order property affect them, and when you would use a filter instead of middleware.

    MVC filters in ASP.NET Core: the five filter stages and their order relative to model binding and result execution, sync vs async filter interfaces, scope ordering and IOrderedFilter, short-circuiting, DI in filters (ServiceFilter, TypeFilter, IFilterFactory), and choosing filters versus middleware versus endpoint filters.

    Mid-Level Theory Request Handling Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  15. What are endpoint filters in Minimal APIs? Write a reusable filter with IEndpointFilter, apply it to a route group, and explain how filter ordering works and what a filter can see and change.

    Coding question on Minimal API endpoint filters: IEndpointFilter and inline AddEndpointFilter, EndpointFilterInvocationContext and argument access, short-circuiting with a result, applying filters to route groups, onion ordering of group and endpoint filters, filter factories, and when to use endpoint filters versus middleware or .NET 10 built-in validation.

    Intermediate Coding Request Handling Β· πŸ”— 2 follow-ups
  16. How do you bind your own types from a request in ASP.NET Core? Show TryParse and BindAsync for Minimal APIs and a custom model binder for controllers, using a strongly typed ID and a comma-separated list as examples, and explain when each is appropriate.

    Coding question on custom binding: IParsable/TryParse for simple types such as strongly typed IDs, static BindAsync for types built from several request parts, custom IModelBinder and IModelBinderProvider for MVC (comma-separated lists), TypeConverter, JSON converters for body properties, and how each affects OpenAPI and validation.

    Mid-Level Coding Request Handling Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  17. How do formatters and content negotiation work in ASP.NET Core? Explain the Accept and Content-Type headers, configuring System.Text.Json options, adding the XML formatter, when you get a 406 or 415, and how Minimal APIs differ from controllers here.

    Input and output formatters and content negotiation: Accept-driven output formatter selection in MVC, ReturnHttpNotAcceptable and 406, Content-Type and 415, JsonOptions for MVC versus Microsoft.AspNetCore.Http.Json.JsonOptions for Minimal APIs, System.Text.Json source generation, adding XML formatters, and Minimal APIs being JSON-only.

    Intermediate Theory Request Handling Β· πŸ”— 2 follow-ups
  18. What is ProblemDetails (RFC 9457), and how do you return consistent error responses in ASP.NET Core? Explain AddProblemDetails, IProblemDetailsService, status code pages, how UseExceptionHandler uses them, and how you add a trace id and your own error codes.

    ProblemDetails in ASP.NET Core .NET 10: the RFC 9457 shape (type, title, status, detail, instance, extensions), ValidationProblemDetails, AddProblemDetails and CustomizeProblemDetails, IProblemDetailsService and IProblemDetailsWriter, UseStatusCodePages for empty error responses, UseExceptionHandler and IExceptionHandler integration, adding traceId and stable error codes, and not leaking internals.

    Mid-Level Theory Request Handling Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  19. A client says your API ignores their data: the request object arrives as null or with default values, or they get a 415, and nothing in the logs explains it. Possible causes include JSON casing, enums sent as strings, a missing [FromBody], the wrong Content-Type, and type mismatches. How do you diagnose and fix it?

    Debugging silent model binding failures in ASP.NET Core: 415 from a wrong or missing Content-Type, null bodies from JSON errors or empty bodies, default values from casing or naming mismatches, enums as strings without JsonStringEnumConverter, number/string and date format mismatches, missing [FromBody] or [ApiController], and the tools to see the real error (ModelState, ThrowOnBadRequest, Debug logging, request logging).

    Mid-Level Debugging Request Handling Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  20. Your API must accept file uploads of up to 2 GB. How do you handle large uploads and streaming request bodies in ASP.NET Core? Compare IFormFile buffering with streaming through MultipartReader or the raw body, explain the size limits at each layer, and how you keep memory use flat.

    Large file uploads in ASP.NET Core: IFormFile buffering to memory and temp disk (FormOptions.MemoryBufferThreshold, MultipartBodyLengthLimit), streaming with MultipartReader or Request.Body/BodyReader, Kestrel MaxRequestBodySize and per-endpoint overrides, MinRequestBodyDataRate, proxy and IIS limits, direct-to-Blob uploads with SAS, validation, malware scanning and anti-forgery.

    Senior Theory Request Handling Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me