📁 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. Should Swagger UI or the OpenAPI document be exposed in production? Explain the risks, how you would secure or environment-gate the docs, and when a public document is the right call.

    Security question on publishing OpenAPI documents and Swagger UI or Scalar in production: reconnaissance risk, leaked internal and admin endpoints, examples containing personal data, UI vulnerabilities and OAuth client settings, and the controls (environment gating, RequireAuthorization on MapOpenApi, separate public documents, API Management developer portals) plus when a public document is the right call.

    Senior Security API Features Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  2. How do endpoint metadata and API Explorer work in ASP.NET Core? Explain WithName, WithTags, Produces, ProducesProblem and TypedResults, and how the same metadata drives the OpenAPI document, link generation and authorisation.

    Theory question on the endpoint metadata collection and IApiDescriptionGroupCollectionProvider: how WithName, WithTags, WithSummary, Produces, ProducesProblem, Accepts, ExcludeFromDescription, IEndpointMetadataProvider on TypedResults and attributes become metadata, and how OpenAPI, LinkGenerator, authorisation, CORS and rate limiting all read from it.

    Mid-Level Theory API Features Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  3. How do you generate the OpenAPI document at build time in ASP.NET Core with Microsoft.Extensions.ApiDescription.Server? Should you commit the spec, and how do you generate C# or TypeScript clients from it with Kiota or NSwag?

    Theory question on generating the OpenAPI document during dotnet build with Microsoft.Extensions.ApiDescription.Server (OpenApiGenerateDocuments, OpenApiDocumentsDirectory, OpenApiGenerateDocumentsOptions, the GetDocument.Insider entry point), whether to commit the spec, and generating C# and TypeScript clients from it with Kiota or NSwag.

    Mid-Level Theory API Features Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  4. How would you use the OpenAPI document as a contract in CI? Explain how you detect breaking changes between versions with a tool like oasdiff, lint the spec, and manage separate documents for each major API version.

    Architecture question on contract-as-code for ASP.NET Core APIs: a committed build-time spec, breaking-change detection with oasdiff against main and released versions, Spectral linting, one OpenAPI document per major version with Asp.Versioning or group names, and how this fits with consumer-driven contract tests.

    Senior Architecture API Features Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  5. What is the difference between OpenAPI and Swagger? Explain why the .NET 9+ web API templates no longer ship Swashbuckle, how the built-in Microsoft.AspNetCore.OpenApi package compares with Swashbuckle and NSwag, and what Swagger UI and Scalar actually do.

    Theory question separating the OpenAPI specification from the Swagger tooling brand, the move from Swashbuckle to Microsoft.AspNetCore.OpenApi in the .NET 9+ templates, how the three document generators compare, and the role of UI viewers such as Swagger UI and Scalar.

    Junior Theory API Features Β· πŸ”— 3 follow-ups
  6. Show me how you configure the built-in OpenAPI support in .NET 10. Use AddOpenApi and MapOpenApi, write document, operation and schema transformers, add a JWT bearer security scheme, and explain what changed when the default moved to OpenAPI 3.1.

    Coding question on Microsoft.AspNetCore.OpenApi in .NET 10: registering and mapping documents, the three transformer types, adding a bearer security scheme and requirements, XML comments, and the OpenAPI 3.1 and Microsoft.OpenApi 2.x changes.

    Intermediate Coding API Features Β· πŸ”— 2 follow-ups
  7. How does SignalR work in ASP.NET Core? Explain hubs, transports and fallback, groups, strongly typed hubs and how you authenticate connections.

    Explains ASP.NET Core SignalR: hubs and the hub lifetime, transport negotiation and fallback, the JSON and MessagePack protocols, groups and users, strongly typed hubs with Hub<T>, IHubContext, and authentication and authorisation for connections.

    Intermediate Theory Real-Time and Special APIs Β· πŸ”— 3 follow-ups
  8. Your product needs live updates in the browser: order status changes, a notification badge and a live dashboard. Compare polling, long polling, Server-Sent Events, WebSockets and SignalR. How does each work, what does each cost, and when would you choose each in ASP.NET Core?

    Compares short polling, long polling, Server-Sent Events, WebSockets and SignalR for pushing updates to clients from ASP.NET Core: mechanism, cost, proxies and when each fits.

    Junior Theory Real-Time and Special APIs Β· πŸ”— 3 follow-ups
  9. Your SignalR app works on one server, but after scaling out to four instances some users stop receiving messages and others get stuck reconnecting. How do you scale SignalR across instances? Explain sticky sessions, the Redis backplane, Azure SignalR Service and connection limits, and how you would design for 100,000 concurrent connections.

    Covers scaling ASP.NET Core SignalR horizontally: why connections and groups are per server, sticky sessions and when they are needed, the Redis backplane, Azure SignalR Service (default and serverless modes, units), connection and message limits, and capacity planning.

    Senior Architecture Real-Time and Special APIs Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. Show me how you implement Server-Sent Events in an ASP.NET Core .NET 10 Minimal API. Stream events from an IAsyncEnumerable, support reconnection with Last-Event-ID, handle heartbeats and client disconnects, and tell me when SSE is a better choice than WebSockets or SignalR.

    Implementing Server-Sent Events in .NET 10 with TypedResults.ServerSentEvents and SseItem<T>: the text/event-stream format, event ids and Last-Event-ID resume, heartbeats, cancellation on disconnect, proxy buffering, and when SSE beats WebSockets or SignalR.

    Mid-Level Coding Real-Time and Special APIs Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. What is gRPC, and how does it work in ASP.NET Core? Explain protobuf contracts, why it needs HTTP/2, the four call types (unary, server streaming, client streaming, bidirectional), deadlines and cancellation, how it compares with REST, and what gRPC-Web and JSON transcoding are for.

    Explains gRPC in ASP.NET Core: .proto contracts and code generation, HTTP/2 framing, unary and streaming calls, deadlines and cancellation, status codes, comparison with REST/JSON, and browser support through gRPC-Web and JSON transcoding.

    Intermediate Theory Real-Time and Special APIs Β· πŸ”— 4 follow-ups
  12. Your gRPC calls work locally but fail in production: behind the load balancer or on Azure App Service some calls return Unavailable or 'protocol error', one pod gets all the traffic, and under load you see a lot of DeadlineExceeded. How do you diagnose and fix these HTTP/2 and timeout problems?

    Diagnosing gRPC failures in production: HTTP/2 not supported end to end, TLS and ALPN, proxies dropping trailers, layer 4 load balancing pinning connections, keep-alive and idle timeouts, the HTTP/2 stream limit, deadline budgets and propagation, with the tools to find each.

    Mid-Level Debugging Real-Time and Special APIs Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  13. What are hosted services in .NET? Explain IHostedService, BackgroundService and the Worker Service template, the lifecycle (StartAsync, ExecuteAsync, StopAsync), what happens at start-up and shutdown, and when you would use a worker instead of running the work inside your web API.

    Explains IHostedService and BackgroundService in .NET 10: registration with AddHostedService, the start-up and shutdown order, ExecuteAsync and its stopping token, the .NET 10 change that runs all of ExecuteAsync in the background, IHostedLifecycleService, the Worker Service template, and in-process versus separate workers.

    Junior Theory Real-Time and Special APIs Β· πŸ”— 3 follow-ups
  14. Your BackgroundService has problems in production: it stopped processing messages hours ago with no alert, a new version blocks the app from starting, and it throws 'Cannot consume scoped service from singleton'. How do you diagnose and fix each one, and how do you make background services observable?

    Diagnosing broken BackgroundService implementations: silent failures and BackgroundServiceExceptionBehavior, start-up blocking (including pre-.NET 10 synchronous ExecuteAsync and slow StartAsync), captive dependencies and IServiceScopeFactory, hangs from ignored cancellation, and health checks and metrics for workers.

    Mid-Level Debugging Real-Time and Special APIs Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  15. You are moving a .NET queue worker that processes payments messages from Azure Service Bus onto Kubernetes (or Azure Container Apps). Walk me through how you would run it in production: graceful shutdown when pods are stopped, making processing idempotent so redelivered messages are safe, and scaling it on queue length with KEDA.

    Running a .NET Worker Service queue consumer on Kubernetes or Azure Container Apps: SIGTERM and graceful shutdown timing, peek-lock and at-least-once delivery, idempotency with an inbox or processed-message table, poison messages, KEDA scaling on queue length, concurrency and probes.

    Senior RealWorldScenario Real-Time and Special APIs Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  16. Show me how you stream a large response from an ASP.NET Core API without buffering it all in memory, for example a 2 million row export. Use IAsyncEnumerable results, explain what can cause buffering anyway, and how you stop the work when the client disconnects using RequestAborted.

    Streaming large responses in ASP.NET Core .NET 10: returning IAsyncEnumerable from Minimal APIs and controllers, System.Text.Json streaming serialisation and flushing, EF Core AsAsyncEnumerable and AsNoTracking, NDJSON and CSV with PipeWriter, things that cause buffering (ToListAsync, middleware, proxies), and cancelling on client disconnect with RequestAborted.

    Mid-Level Coding Real-Time and Special APIs Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

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