📁 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.

Real-Time and Special APIs

SignalR, WebSockets, Server-Sent Events, gRPC, gRPC-Web, streaming APIs, background services, worker services and hosted services.

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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