.NET Core and .NET 8 Interview Questions
Last updated 2026-11-19
.NET interviews now centre on modern .NET (the line that began as .NET Core and continues as .NET 5 to 8 and beyond), not the old Windows-only Framework. The questions concern the runtime, the hosting model, the middleware pipeline, dependency injection, configuration and how applications are deployed.
This page covers the platform. Controller, routing and view specifics are on the ASP.NET Core MVC page, and the language is on the C# interview questions page.
| Platform | .NET 8 (long-term support release) |
|---|---|
| Runtime | CLR with tiered JIT, optional Native AOT |
| Hosting | Kestrel, optionally behind IIS, Nginx or a gateway |
Terms people mix up
- .NET Framework: the original Windows-only runtime, in maintenance mode.
- .NET Core: the cross-platform rewrite; since version 5 it is simply called .NET.
- .NET Standard: an API specification for libraries, mostly obsolete now that libraries target net6.0, net8.0 and so on.
- CLR: the runtime that executes IL; BCL: the base class library.
.NET Core and .NET 8 Interview Questions: questions with worked answers
1 What is the difference between .NET Framework, .NET Core and modern .NET?
easy.NET Framework runs only on Windows and ships with the OS. .NET Core, released in 2016, is cross-platform, open source, modular and faster, with side-by-side versions per application. From .NET 5 the name dropped "Core" and the platform unified; even-numbered releases (6, 8) are long-term support. New projects should target the latest LTS, and Framework is used only for legacy code that depends on Windows-only technologies.
2 What are CLR, CTS, CLS, BCL and JIT?
easyThe CLR executes managed code, handling memory, type safety, exceptions and threads. The CTS defines the common types all .NET languages share and the CLS is the subset of features that languages must support to interoperate. The BCL is the base class library of System.* types. The JIT compiles intermediate language (IL) to machine code at run time, with tiered compilation starting fast and re-optimising hot methods.
3 How does a .NET 8 web app start? Explain Program.cs and the host.
mediumThe WebApplication builder registers services into a dependency injection container, loads configuration and logging, then Build creates the app, where you configure the middleware pipeline and endpoints. Run starts the host, which runs Kestrel and listens for requests. This minimal hosting model replaced the separate Startup class.
csharpvar builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddScoped<IOrderService, OrderService>(); var app = builder.Build(); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.MapGet("/ping", () => "pong"); app.Run();4 What is middleware, and why does the order matter?
mediumMiddleware are components in a request pipeline, each of which can handle the request, call the next delegate and then act on the response on the way back. They run in the order registered, so exception handling must come first to catch errors from everything after it, authentication before authorisation, and routing before endpoints. Use adds a step that may call next, Run is terminal, and Map branches the pipeline by path.
csharpapp.Use(async (ctx, next) => { Console.WriteLine("before"); await next(ctx); Console.WriteLine("after"); }); app.Run(async ctx => await ctx.Response.WriteAsync("hello")); // request prints: before, then the response is produced, then after5 Explain the three dependency injection lifetimes and the captive dependency bug.
mediumTransient creates a new instance each time it is resolved, scoped one per scope (per HTTP request in ASP.NET Core) and singleton one for the application. A captive dependency happens when a longer-lived service holds a shorter-lived one, for example a singleton that injects a scoped DbContext, which then lives for the whole application and is not thread safe. The default container validates scopes in the Development environment to catch it. Create a scope manually with IServiceScopeFactory inside singletons.
csharpservices.AddTransient<IClock, Clock>(); services.AddScoped<AppDbContext>(); // per request services.AddSingleton<ICache, MemoryCacheAdapter>(); // BAD: a singleton taking AppDbContext in its constructor6 How does configuration work in .NET, and what is the options pattern?
mediumConfiguration is layered from providers in order, with later ones overriding earlier ones: appsettings.json, appsettings.{Environment}.json, user secrets in Development, environment variables and command-line arguments. The options pattern binds a section to a typed class and injects it as IOptions<T> (fixed at startup), IOptionsSnapshot<T> (per request) or IOptionsMonitor<T> (live change notifications). Secrets should never be in source control.
csharpbuilder.Services.Configure<SmtpOptions>(builder.Configuration.GetSection("Smtp")); public class Mailer(IOptions<SmtpOptions> opt) { private readonly SmtpOptions _o = opt.Value; } // environment variable form: Smtp__Host=mail.example.com7 What is Kestrel, and do you need IIS or Nginx in front of it?
easyKestrel is the cross-platform web server built into ASP.NET Core and is fast and production-ready on its own. A reverse proxy such as IIS, Nginx, YARP or a cloud load balancer adds TLS termination, request filtering, multiple sites on a port, process management and sometimes security hardening. Behind a proxy, enable forwarded headers so the app sees the original scheme and client IP.
8 Framework-dependent versus self-contained deployment, and what is Native AOT?
mediumFramework-dependent publish needs the matching .NET runtime on the machine and produces a small output. Self-contained includes the runtime, so it runs anywhere without installation at a larger size. Native AOT compiles to a native executable with no JIT, giving fast startup and lower memory, but it requires trim-safe code, limits reflection and dynamic loading, and in ASP.NET Core supports minimal APIs rather than MVC controllers.
csharpdotnet publish -c Release -r linux-x64 --self-contained false dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=true dotnet publish -c Release -r linux-x64 -p:PublishAot=true9 Controllers versus minimal APIs: when would you use each?
mediumMinimal APIs map handlers directly to routes with very little ceremony, start faster and suit small services and microservices; endpoint filters and route groups cover cross-cutting concerns. Controllers provide conventions for larger apps: attribute routing, model binding, filters, API behaviours and content negotiation. Both run on the same pipeline and can coexist in one project.
csharpvar api = app.MapGroup("/api/items"); api.MapGet("/{id:int}", (int id, IItemRepo repo) => repo.Find(id) is { } item ? Results.Ok(item) : Results.NotFound()); api.MapPost("/", (Item item, IItemRepo repo) => Results.Created($"/api/items/{item.Id}", repo.Add(item)));10 How does .NET handle threading and why does async matter for web servers?
mediumRequests are served by threads from the thread pool, which grows slowly. If a handler blocks a thread while waiting for a database or HTTP call, throughput collapses under load, so I/O work should use async and await, which return the thread to the pool until the operation completes. ASP.NET Core has no synchronisation context, so async code does not deadlock on .Result as old ASP.NET did, but blocking still starves the pool. See async and await.
11 What logging and health-check features are built in?
mediumILogger<T> is injected anywhere and writes through configured providers (console, debug, EventSource and third-party ones such as Serilog); use message templates with named placeholders, not string interpolation, so logs stay structured. Health checks (AddHealthChecks and MapHealthChecks) expose liveness and readiness endpoints for orchestrators such as Kubernetes, and can include database checks.
csharplogger.LogInformation("Order {OrderId} created for {User}", order.Id, user); builder.Services.AddHealthChecks(); app.MapHealthChecks("/healthz");12 How do you use environments in ASP.NET Core?
mediumASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT sets the environment name, defaulting to Production, and Development, Staging and Production are the conventional values. app.Environment.IsDevelopment() branches behaviour such as the developer exception page and Swagger, and environment-specific appsettings files are layered on top of the base file.
13 What changed for performance in modern .NET?
mediumTiered and dynamic PGO optimise hot code from runtime profiles, Span<T> and Memory<T> allow slicing arrays and strings without copying, and ArrayPool<T> reuses buffers. System.Text.Json is the default high-performance serialiser, with source generators for reflection-free paths. Frozen collections such as FrozenDictionary speed up read-only lookups. Measure with BenchmarkDotNet before optimising.
14 What is NuGet and what does a modern .csproj look like?
easyNuGet is the package manager; packages are referenced with PackageReference entries in the project file and restored by dotnet restore. SDK-style projects are short: a Sdk attribute, a TargetFramework such as net8.0, properties like Nullable and ImplicitUsings, and package references, with source files included by default.
csharp<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> </Project>15 How does the CLR load assemblies and what is the difference between an assembly and a namespace?
hardAn assembly is the deployable unit (a DLL or EXE) holding IL, metadata and a manifest with its name, version and references. A namespace is a logical grouping of type names, and one assembly can contain many namespaces while one namespace can span many assemblies. The runtime resolves references using the app's .deps.json file and probing paths; AssemblyLoadContext allows isolated loading of plugins and unloading.
Frequently asked questions
Is .NET Core still relevant, or is it just .NET now?
The name is just .NET, but interviewers still say .NET Core for the cross-platform line. Know the difference from .NET Framework.
Which .NET version should I learn?
.NET 8, the current long-term support release at the time of writing, with C# 12.
What is the difference between IApplicationBuilder.Use and Run?
Use can call the next middleware; Run terminates the pipeline.
What is next after this page?
Study ASP.NET Core MVC and Entity Framework Core, then compare with Spring Boot.
Related guides
More in Programming Language Interview Questions by Language
- Advanced Python Interview Questions
- ASP.NET Core MVC Interview Questions
- C Language Interview Questions and Answers
- C Pointers Interview Questions
- C Programming Output Questions with Answers
- C# Async Await Interview Questions
- C# Coding Interview Questions
- C# Collections Interview Questions
- C# Delegates and Events Interview Questions
- C# Interview Questions and Answers
- C# LINQ Interview Questions
- C# OOPs Interview Questions