Skip to main content
InterviewHubPRO
HomeTracksSection 27: ASP.NET Core & Web API (50 Qs)
Section 27 of 6450 Questions (1 Per Page)

ASP.NET Core, Web API & Enterprise Cloud Architecture Master Interview Bank

ASP.NET Core middleware pipeline, DI lifetimes, Minimal APIs, Entity Framework Core, JWT & policy authorization, Kestrel tuning, and Microservices.

Curriculum Roadmap & Learning Path

3 Stages
Tip: Click any stage card above to instantly filter the question bank to that topic.3 Connected Milestones
50 of 50 Qs

Part 1: Request Pipeline, Dependency Injection & Web APIs (1 - 10)

10 Questions
1
Most AskedSeniorCode#Dependency Injection#Pipes

Walk through the ASP.NET Core Request Middleware Pipeline.

The HTTP request pipeline is a sequence of delegate functions (RequestDelegate) arranged in bidirectional order: Request arrives at Kestrel web server • Passes through middleware components in registered order: ExceptionHandler -> Hsts -> HttpsRedirection -> StaticFiles -> Routing -> Cors ->.

2
Most AskedMidCode#Dependency Injection#Pipes

Explain Dependency Injection Lifetimes in ASP.NET Core: Transient vs. Scoped vs. Singleton.

Transient (AddTransient): New instance created every single time it is requested • Scoped (AddScoped): Exactly one instance created per HTTP request lifecycle • Singleton (AddSingleton): Exactly one instance created on first request and shared across the entire application lifetime.

3
Most AskedJuniorCode#Dependency Injection#Pipes

What are Minimal APIs in .NET 8, and how do they compare to Controller-based APIs?

Controllers: Class-based, uses reflection and attribute routing ([ApiController], [HttpGet]), heavier startup overhead and boilerplate • Minimal APIs (introduced .NET 6, optimized .NET 8): Lambda-based route endpoints registered directly on WebApplication.

4
Most AskedMid#Dependency Injection#Pipes

How does Kestrel work, and why is it used in front of or behind Reverse Proxies?

Kestrel is a cross-platform, asynchronous, high-throughput web server built directly into .NET: In production, Kestrel runs directly or behind an edge reverse proxy (Nginx, YARP, AWS ALB, Azure App Gateway).

5
Most AskedSenior#Dependency Injection#Pipes

What are Action Filters and Endpoint Filters in ASP.NET Core?

Action Filters: Intercept controller action invocation (OnActionExecuting, OnActionExecuted), enabling cross-cutting concerns like validation • Endpoint Filters (.NET 7+): Middleware-like filters applied to specific Minimal API routes or route groups, wrapping the endpoint handler execution.

6
Most AskedMidCode#Dependency Injection#Pipes

How do you implement Centralized Global Exception Handling in .NET 8?

Implement IExceptionHandler in .NET 8 and register it with app.UseExceptionHandler(): Intercepts uncaught exceptions cleanly without try-catch duplication across controllers • Returns RFC-7807 compliant ProblemDetails payloads.

7
Most AskedJunior#Dependency Injection#Pipes

What is `CancellationToken` and why must you pass it to all async database and HTTP calls?

A CancellationToken notifies async operations that the client disconnected or the request timed out: If a user cancels an HTTP request or navigates away, passing CancellationToken to EF Core (SaveChangesAsync(ct)) or HttpClient immediately.

8
Most AskedMid#Dependency Injection#Pipes

How does Configuration and Options Pattern (`IOptionsSnapshot`, `IOptionsMonitor`) work in .NET?

The Options Pattern provides strongly typed access to settings in appsettings.json: IOptionsT: Singleton; bound once at startup • IOptionsSnapshotT: Scoped; recomputed once per HTTP request • IOptionsMonitorT: Singleton; listens for file reload events and provides real-time notifications (OnChange).

9
Most AskedMid#Dependency Injection#Pipes

How does Rate Limiting work natively in .NET 7/8 (`Microsoft.AspNetCore.RateLimiting`)?

Built-in middleware providing 4 standard rate limiting algorithms: Fixed Window: Allows X requests per fixed time period • Sliding Window: Divides time into segments, preventing burst spikes at window boundaries • Token Bucket: Accumulates tokens at a steady rate with a burst capacity.

10
Most AskedMid#Dependency Injection#Pipes

How do you implement Background Services (`IHostedService` & `BackgroundService`)?

Implement BackgroundService to run long-running background workers, queue consumers, or scheduled jobs inside ASP.NET Core: Executes ExecuteAsync(CancellationToken stoppingToken) in a background thread • Important: To use scoped services (like DbContext) inside a singleton background worker, you must manually create a scope via.

Part 2: Entity Framework Core, Security & High-Performance Data (11 - 24)

14 Questions
11
Most AskedJunior#Forms#Performance

What is Output Caching vs. Response Caching in ASP.NET Core?

Response Caching: Relies on HTTP cache headers (Cache-Control) directed primarily at clients and intermediate CDN proxies • Output Caching (.NET 7+): Server-side caching of endpoint response payloads with tag-based cache eviction (EvictByTagAsync), cache locking.

12
Junior#Forms#Performance

What are Health Checks in ASP.NET Core (`AspNetCore.HealthChecks`)?

Exposes liveness and readiness probes (/health/live, /health/ready) to Kubernetes or load balancers: Liveness: Confirms the .NET process is alive and responsive • Readiness: Confirms external dependencies (SQL database connection, Redis, RabbitMQ) are reachable before routing user traffic.

13
Junior#Forms#Performance

What is YARP (Yet Another Reverse Proxy)?

A high-performance reverse proxy toolkit created by Microsoft, built on top of ASP.NET Core infrastructure: Enables building custom API Gateways, load balancers, blue-green deployment routers, and authentication proxies with full C# customization.

14
Junior#Forms#Performance

How does Content Negotiation work in Web APIs?

The server inspects the client's HTTP Accept header (e.g., application/json, application/xml) and uses registered OutputFormatters to serialize the response into the requested format.

15
Junior#Forms#Performance

How do you implement Graceful Shutdown on .NET Web Apps?

When receiving SIGTERM: Host triggers IHostApplicationLifetime.ApplicationStopping • Kestrel stops accepting new connections • In-flight requests are allowed to complete up to HostOptions.ShutdownTimeout (default 30s) • IHostedService.StopAsync is invoked sequentially on all background workers.

16
JuniorCode#Forms#Performance

What is the difference between `AsNoTracking()` and Tracking queries in EF Core?

Tracking (Default): EF Core's ChangeTracker stores a snapshot of every entity in memory • AsNoTracking(): Disables snapshot tracking.

17
MidCode#Forms#Performance

How does EF Core solve the N+1 Query Problem (`Include` vs. `AsSplitQuery`)?

Problem: Accessing order.Items in a loop executes N separate queries • Eager Loading: Include(o => o.Items) loads related data using an SQL LEFT JOIN • Cartesian Explosion: Joining multiple one-to-many collections generates massive redundant data over the network.

18
Mid#Forms#Performance

How does Compiled Models (`Optimize-DbContext`) improve startup time in EF Core 8?

EF Core generates metadata models dynamically using reflection on first use, which slows application cold starts. Running dotnet ef dbcontext optimize generates pre-compiled C# code representing the database model, reducing first-query latency from seconds to milliseconds.

19
MidCode#Forms#Performance

When should you use Dapper over Entity Framework Core?

Dapper: A lightweight Micro-ORM that extends IDbConnection with high-speed object mapping • EF Core 8: Full ORM with migrations, ChangeTracker, LINQ type safety, and relationship graphs • Modern Hybrid Architecture: Use EF Core for domain entity commands and transactional mutations; use Dapper or EF Core SqlQueryT for.

20
Junior#Forms#Performance

How does EF Core 8 handle Primitive Collections and JSON Columns?

EF Core 8 natively maps primitive arrays (int[], List) and complex JSON documents directly to database jsonb (Postgres) or json (SQL Server) columns: Supports querying inside JSON arrays directly using LINQ Contains() • Updates modify specific JSON properties without rewriting the whole document.

21
Junior#Forms#Performance

What are Global Query Filters and how are they used for Soft Delete & Multi-Tenancy?

A query filter applied automatically to all queries for an entity type in OnModelCreating: Soft Delete: modelBuilder.EntityUser().HasQueryFilter(u => !u.IsDeleted); • Any context.Users.ToList() automatically adds WHERE IsDeleted = 0.

22
Mid#Forms#Performance

How do Database Migrations work in production without downtime?

Never call context.Database.Migrate() on application startup in production (risk of concurrency race conditions when multiple pods start simultaneously).: Generate idempotent SQL scripts: dotnet ef migrations script -i -o migrate.sql.

23
Senior#Forms#Performance

What is the difference between Optimistic Concurrency and RowVersion in EF Core?

Uses a [Timestamp] or IsRowVersion() byte array column • SQL Server automatically increments the RowVersion binary on every update • EF Core adds WHERE RowVersion = @originalVersion.

24
Junior#Forms#Performance

What is Connection Resiliency and Execution Strategies in EF Core?

Automatically retries failed database commands caused by transient network glitches: Configure EnableRetryOnFailure(maxRetryCount: 5, maxRetryDelay: TimeSpan.FromSeconds(30), null) • When using user-initiated explicit transactions, you must wrap them in executionStrategy.ExecuteAsync().

Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)

26 Questions
25
Senior#System Design

What is the difference between `AddDbContext` vs. `AddDbContextPool`?

AddDbContext: Instantiates a new DbContext instance per HTTP request and discards it after • AddDbContextPool: Maintains a pool of reusable DbContext instances.

26
Most AskedSenior#Security & Auth#System Design

How does JWT Authentication and Refresh Token Rotation work in ASP.NET Core?

Configure builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(...) • Validate Issuer, Audience, IssuerSigningKey, and clock skew • Access tokens expire quickly (15 mins) • Refresh tokens are stored in the database with a family ID.

27
Senior#Security & Auth#System Design

What is Policy-Based and Claims-Based Authorization?

Claims: Key-value pairs issued by identity provider (e.g., Department = "Finance", ClearanceLevel = "TopSecret") • Policies: Registered requirements evaluating claims • Enforced on endpoints via [Authorize(Policy = "RequireFinanceAdmin")].

28
Senior#System Design#Databases & SQL

How do you protect against SQL Injection in .NET?

LINQ queries in EF Core are parameterized by default • If raw SQL is needed, always use string interpolation with FromSqlInterpolated or FromSql which automatically parameterizes variables.

29
Senior#System Design#HTTP & REST APIs

What is Data Protection API (DPAPI) in ASP.NET Core?

Provides cryptographic APIs for protecting sensitive data at rest (cookie encryption, anti-forgery tokens, password reset tokens): Automatically manages cryptographic key generation and rotation • In multi-pod production environments, keys must be persisted to a shared location (Redis or Azure Blob) and protected with a master key (Azure.

30
Most AskedSenior#Security & Auth#System Design

How do you prevent Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF)?

XSS: Razor and Blazor encode HTML output by default • CSRF: Use [AutoValidateAntiforgeryToken] or IAntiforgery for cookie-authenticated web apps.

31
Senior#System Design

How does Secure Password Hashing work with ASP.NET Core Identity?

ASP.NET Core Identity uses PasswordHasherT which implements PBKDF2 with HMAC-SHA512, using a 128-bit salt and 100,000 iterations by default.

32
Most AskedSenior#Security & Auth#System Design

How do you configure CORS securely in ASP.NET Core?

Never use AllowAnyOrigin() with AllowCredentials() in production: Explicitly whitelist trusted origins (WithOrigins("https://app.company.com")), restrict allowed HTTP methods (GET, POST), and specify allowed headers.

33
Senior#System Design

What is Clean Architecture / Hexagonal Architecture in .NET?

Organizes code into concentric layers with strict inward dependency rule: Domain (Core): Entities, Value Objects, Domain Exceptions (Zero dependencies) • Application: Use Cases, Commands, Queries, DTOs, Interfaces (Depends only on Domain).

34
SeniorCode#System Design

What is CQRS and how does MediatR implement the Mediator Pattern?

CQRS (Command Query Responsibility Segregation): Separates read operations (Queries) from write operations (Commands) • MediatR: Decouples sender and handler • IRequestTResponse dispatched via ISender.Send(command).

35
Senior#System Design#gRPC

How does gRPC work in .NET and when is it preferred over REST?

A high-performance RPC framework using Protocol Buffers (protobuf) binary serialization over HTTP/2: 7–10x faster serialization and significantly smaller payloads than JSON • Strongly typed contracts via .proto files • Supports bi-directional streaming • Ideal for internal service-to-service microservice communication.

36
SeniorCode#System Design#HTTP & REST APIs

Minimal APIs vs Controller-Based APIs in ASP.NET Core.

Controllers ([ApiController]): Traditional approach • Minimal APIs (app.MapGet(...)): Introduced in .NET 6/7 • Endpoint Filters (AddEndpointFilter): Intercepts requests on Minimal APIs for validation, logging, and metrics without creating complex.

37
Senior#Pipes#CI/CD & DevOps

The Middleware Pipeline: Execution Order and Short-Circuiting.

ASP.NET Core processes requests through a bidirectional pipeline of middleware components: Russian-Doll Model: Each middleware executes logic before invoking await next(), passing control down the chain, and executes post-processing.

38
Senior#System Design

Kestrel Web Server Internals and Socket Transport.

Kestrel is the default cross-platform web server for ASP.NET Core: Built on high-performance socket transport using Linux epoll and Windows I/O Completion Ports (IOCP).

39
SeniorCode#Security & Auth#System Design

Policy-Based Authorization: Requirements and Handlers.

Beyond simple role checks ([Authorize(Roles = "Admin")]), policy-based authorization decouples permissions from business logic: Policy: Composed of one or more Requirements (e.g. MinimumAgeRequirement(21)).

40
Most AskedSeniorCode#System Design

Native Rate Limiting Middleware in .NET 7/8+.

Built-in rate limiting (Microsoft.AspNetCore.RateLimiting) protects endpoints from denial-of-service without external proxies: Fixed Window: Allows N requests per calendar interval • Sliding Window: Smooths out traffic spikes across window segments.

41
Most AskedSenior#System Design

Output Caching vs Response Caching.

Response Caching (UseResponseCaching): Relies on HTTP headers (Cache-Control) respected by browser or proxy caches • Output Caching (UseOutputCache .NET 7+): Enterprise server-side caching.

42
Senior#System Design#Golang

Background Tasks and Hosted Services with Channels.

BackgroundService: Base class implementing IHostedService to run long-running background loops • System.Threading.Channels: High-performance, lock-free producer-consumer queue in memory.

43
Senior#Forms#Performance

Entity Framework Core Performance: `AsNoTracking` and Split Queries.

AsNoTracking(): Tells EF Core not to cache entities in the ChangeTracker • Split Queries (AsSplitQuery()): When loading multiple child collections (.Include(o => o.Items).Include(o => o.Notes)), relational databases.

44
Senior#System Design

Enterprise Health Checks: Readiness vs Liveness Probes.

Configured via services.AddHealthChecks(): Liveness Probe (/healthz/live): Reports if the process is running • Readiness Probe (/healthz/ready): Reports if the application is ready to accept user traffic (verifies database connections, Redis pings, and.

45
Senior#Signals#System Design

Real-Time Communication with SignalR and Redis Backplane.

SignalR provides bidirectional real-time communication between server and clients: Automatically negotiates best transport: WebSockets -> Server-Sent Events -> Long Polling • Redis Backplane: In scaled environments with multiple web servers, Client A on Server 1 and Client B on Server 2 communicate via a Redis Pub/Sub.

46
Senior#Forms#System Design

FluentValidation vs DataAnnotations in ASP.NET Core.

DataAnnotations ([Required], [EmailAddress]): Inlines validation rules as attributes on model classes • FluentValidation: Separates validation rules into dedicated classes (AbstractValidatorUserDTO).

47
SeniorCode#CLI#Pipes

Resilient HTTP Clients with Polly Resilience Pipelines.

Calling external microservices using raw HttpClient risks socket exhaustion and cascading outages.: IHttpClientFactory: Manages underlying HttpMessageHandler lifetimes to prevent DNS caching bugs and socket exhaustion.

48
Senior#System Design

Standardized Error Handling with Problem Details (RFC 7807).

Problem Details (RFC 7807) is an IETF standard defining a consistent JSON structure for HTTP error responses: Includes type, title, status, detail, and instance • In .NET 7/8+, builder.Services.AddProblemDetails() automatically formats all unhandled exceptions and validation errors into compliant RFC 7807.

49
Senior#System Design

Configuration & Options Pattern: `IOptions` vs `IOptionsSnapshot` vs `IOptionsMonitor`.

IOptionsT: Singleton lifetime • IOptionsSnapshotT: Scoped lifetime • IOptionsMonitorT: Singleton lifetime.

50
Senior#System Design

Multi-Tenant Architecture in ASP.NET Core.

Database-per-Tenant: Highest security isolation • Schema-per-Tenant: Shared database, separate schema per tenant • Shared Database with Discriminator Column: All tenants share tables with a TenantId column.