In this article
  1. The platform
  2. Memory and the garbage collector
  3. ASP.NET Core and web requests
  4. Asynchronous code and LINQ
  5. Data access
  6. Follow-up questions
  7. Sources

The platform

For the general method, see coding interview preparation, how to answer interview questions and how interview loops are structured; the sibling list for another stack is Angular interview questions.

What is .NET, and how does it relate to .NET Core and .NET Framework?

.NET is Microsoft's cross-platform, open-source development platform, and ".NET Core" is the name of the modern line that replaced the Windows-only .NET Framework. Microsoft's lifecycle FAQ says the two have a subset-superset relationship and share the garbage collector, the just-in-time compiler and types such as String and List<T> (Microsoft Learn, updated November 2025). Newer releases are simply called ".NET" with a number.

Why it is asked: the naming confuses many candidates, and a clear answer shows current knowledge. Read more: coding interview preparation.

What are LTS and STS releases?

Long-term support (LTS) and standard-term support (STS) are the two support tracks for .NET releases, and the only difference is support length: Microsoft's policy says LTS releases get free support and patches for three years and STS releases for two years (.NET support policy, read October 2026). A major release ships once a year around November; even-numbered releases are LTS and odd-numbered ones are STS (Microsoft Learn, updated November 2025). Microsoft's policy table lists .NET 8 (LTS) and .NET 9 (STS) both ending support on 10 November 2026, and .NET 10 (LTS) running to 14 November 2028 (.NET support policy, read October 2026).

Why it is asked: choosing a version is a real maintenance decision.

What is the common language runtime?

The common language runtime (CLR) is the execution engine of .NET: it loads compiled code, compiles it to machine code with a just-in-time (JIT) compiler as needed, and provides services such as memory management and type safety. Microsoft describes the CLR's garbage collector as its automatic memory manager (Microsoft Learn, updated October 2025). Code that runs under it is called managed code.

Why it is asked: it tests whether you know what runs your code.

What is the difference between a value type and a reference type?

A value type stores its data directly in the variable, and assigning it copies the data; a reference type stores a reference to an object, and assigning it copies the reference so both variables see the same object. Structures and numeric types are value types; classes are reference types. Microsoft's garbage collection page notes that all reference types are allocated on the managed heap (Microsoft Learn, updated October 2025).

Why it is asked: it underlies equality, copying and performance questions.

Memory and the garbage collector

How does garbage collection work in .NET?

The garbage collector (GC) is the CLR component that finds objects the program can no longer reach and frees their memory. It starts from roots such as static fields and local variables, marks everything reachable, and releases the rest, compacting survivors when worthwhile. Collection runs when physical memory is low, when allocations pass a threshold, or when GC.Collect is called, which is rarely needed (Microsoft Learn, updated October 2025).

Why it is asked: memory behaviour explains many production problems.

What are GC generations?

The managed heap is divided into generations 0, 1 and 2 so short-lived and long-lived objects are handled separately. New objects go into generation 0, objects that survive a collection are promoted to generation 1 and then 2, and collecting a generation also collects the younger ones; a generation 2 collection is a full collection (Microsoft Learn, updated October 2025). Most objects die young, which makes generation 0 collections cheap.

Why it is asked: it shows you can reason about allocation cost.

What is the large object heap?

The large object heap (LOH) is a separate part of the heap for objects of 85,000 bytes or more, usually arrays. Microsoft says the LOH is normally not compacted because copying large objects is costly, and that it is collected together with generation 2 (Microsoft Learn, updated October 2025). Frequent large allocations can therefore fragment memory and trigger expensive full collections.

Why it is asked: it is a common cause of memory pressure in services.

What is IDisposable and when do you call Dispose?

IDisposable is an interface for releasing unmanaged resources such as file handles and network connections, which the garbage collector does not know how to clean up. Microsoft recommends providing a public Dispose method and calling it when you finish with such an object; a using statement does this for you (Microsoft Learn, updated October 2025). Forgetting to dispose leaks the underlying resource until finalisation.

Why it is asked: leaked handles cause outages that memory graphs do not show.

Knowing it is half the job. Saying it is the other half.

Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.

Start Free Trial →

ASP.NET Core and web requests

What is middleware in ASP.NET Core?

Middleware is a component in the request pipeline that handles a request, may call the next component, and can act both before and after it. ASP.NET Core builds the pipeline from request delegates configured with Run, Map and Use, called one after the other (ASP.NET Core middleware documentation, August 2026). A delegate that does not call the next one short-circuits the pipeline, as static file handling can.

Why it is asked: the pipeline is the heart of every ASP.NET Core app.

A request passes through each middleware and the response returnsSequence: the client sends a request to middleware A, which calls next to middleware B, which calls next to the endpoint; the endpoint's response returns through B and A to the client. A middleware that skips next returns early.ClientMiddlewareAMiddlewareBEndpointrequestskip next =return earlynextnextresponseresponseresponseDiagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/net-core-interview-questions-and-answers.html
A middleware that skips next returns early; otherwise the response passes back through each one.CC BY 4.0 — source: .NET Core interview questions answered: GC, DI, middleware, async, EF Core
Text description of the diagram
  • Middleware runs in the order it is added.
  • A delegate that does not call the next one short-circuits the pipeline.

Why does middleware order matter?

Middleware runs in the order it is added, so a component only sees what earlier ones have done. Microsoft's example is that cross-origin request handling must be called before authentication, and a delegate added after a terminal Run delegate is never called (Microsoft Learn, August 2026). A common bug is placing authorization before the step that identifies the user.

Why it is asked: ordering mistakes are a frequent real-world defect.

What is dependency injection and why does ASP.NET Core use it?

Dependency injection (DI) is a technique where a class receives the objects it depends on from outside instead of creating them. ASP.NET Core has a built-in service container; Microsoft lists the benefits as swapping implementations without changing consumers, centralised configuration of dependencies and easier unit testing (Microsoft Learn, September 2026). You register services at startup and request them through constructors.

Why it is asked: it is the standard way to structure .NET code.

What is the difference between transient, scoped and singleton services?

A transient service is created each time it is requested, a scoped service is created once per request (or per Blazor circuit), and a singleton is created once and shared by every request. Microsoft's example shows transient objects always differ, scoped objects are the same within one request, and singletons are the same for every request (Microsoft Learn, September 2026).

Why it is asked: choosing the wrong scope causes subtle bugs.

What goes wrong if a singleton depends on a scoped service?

The scoped service is captured and effectively becomes a singleton, so per-request state leaks across requests. Microsoft gives a related case: injecting a scoped service into middleware through its constructor throws a runtime exception because it forces the scoped service to behave like a singleton; inject it into InvokeAsync instead (Microsoft Learn, September 2026). A database context is registered as scoped by default.

Why it is asked: it is the classic dependency injection trap.

Why use IHttpClientFactory instead of creating HttpClient yourself?

IHttpClientFactory pools and recycles the underlying message handlers. Microsoft's documentation says it avoids resource exhaustion from creating too many handlers and avoids stale Domain Name System (DNS) results by cycling handlers at regular intervals; the default handler lifespan is two minutes (Microsoft Learn, October 2026). Creating and disposing a new client per request can exhaust sockets.

Why it is asked: it tests knowledge of a known production pitfall. Read more: system design preparation.

Asynchronous code and LINQ

What does async and await do?

Calling an async method starts the work and returns a Task that represents it; await pauses the calling method until that task finishes, without blocking the thread, and then resumes it. Microsoft stresses that async code is not the same as parallel code: one thread can run many tasks by starting the next before the previous finishes, and blocking threads on work that could be awaited limits how cheaply a server scales (Microsoft Learn, March 2025). A method that awaits anything is itself asynchronous.

Why it is asked: misuse of async is a leading cause of slow or deadlocked services.

How do you run several asynchronous operations together?

Start all the tasks first, then await them together. The pattern is to store each Task and then use Task.WhenAll, which completes when all tasks complete, or Task.WhenAny, which completes when the first does (Microsoft Learn, March 2025). Awaiting each call straight away runs them one after another, which is slower when they are independent.

Why it is asked: it separates sequential from concurrent thinking.

What is deferred execution in LINQ?

Deferred execution in Language Integrated Query (LINQ) means a query is not evaluated until its result is needed. Microsoft defines it as delaying evaluation of an expression until its realised value is required, which can improve performance with chained queries (LINQ deferred execution page). The practical risk is that enumerating a LINQ result twice runs it twice; call ToList to materialise it once.

Why it is asked: it explains surprising behaviour and repeated database calls.

Data access

What is the difference between tracking and no-tracking queries in EF Core?

A tracking query makes Entity Framework (EF) Core remember each returned entity so that changes are saved by SaveChanges; a no-tracking query skips that. Microsoft says no-tracking queries suit read-only results and are generally quicker because no change-tracking information is set up, and you request them with AsNoTracking (EF Core tracking documentation). Queries that return entity types are tracked by default.

Why it is asked: it is the first performance question about data access.

What is the N+1 query problem?

The N+1 problem is one query to load a list followed by one extra query per item to load related data, so an illustrative list of 100 items causes 101 round trips. It comes from lazily loading a relationship inside a loop. The usual fixes are to include the related data in the original query or to project only the columns you need, then check the generated Structured Query Language (SQL).

Why it is asked: it is the most common cause of slow endpoints.

Follow-up questions

Does the dependency injection container dispose the services it creates?

Yes for the ones it creates: Microsoft's documentation says the container calls Dispose for the IDisposable types it creates, and that you should never dispose a service you resolved from it. Services you construct yourself and hand to the container, such as AddSingleton(new Service1()), are not created by it (Microsoft Learn, September 2026).

When is the large object heap compacted?

Not by default. Microsoft says you can compact it on demand with the GCSettings.LargeObjectHeapCompactionMode property, and that it is compacted automatically when a hard limit is set, either as a memory limit on a container or with the GCHeapHardLimit setting (Microsoft Learn, October 2025).

Can one static HttpClient replace IHttpClientFactory?

Yes, if you manage it carefully. Microsoft describes one shared SocketsHttpHandler created at startup and reused for as long as the app runs, with its pooled-connection setting chosen from your DNS refresh times, and clients made with new HttpClient(handler, disposeHandler: false); this solves the same resource and stale-DNS problems (Microsoft Learn, October 2026).

Key takeaways
  • .NET Core is the modern line of .NET; even-numbered releases are long-term support and odd-numbered ones are standard-term support.
  • The garbage collector uses generations 0, 1 and 2 and a separate large object heap for objects from 85,000 bytes.
  • Middleware runs in order and can short-circuit; order mistakes are real bugs.
  • Pick service scopes deliberately: a singleton must never capture a scoped service.
  • Start independent tasks first and await them together; materialise LINQ queries you enumerate more than once.

Sources

  1. Lifecycle FAQ - .NET and .NET Core — Microsoft Learn, 24 Nov 2025
  2. .NET and .NET Core official support policy — Microsoft, 24 Oct 2026
  3. Dependency injection in ASP.NET Core — Microsoft Learn, 22 Sep 2026
  4. ASP.NET Core middleware — Microsoft Learn, 19 Aug 2026
  5. Fundamentals of garbage collection — Microsoft Learn, 22 Oct 2025
  6. Asynchronous programming in C# — Microsoft Learn, 10 Mar 2025
  7. Make HTTP requests using IHttpClientFactory in ASP.NET Core — Microsoft Learn, 8 Oct 2026
  8. Tracking vs. no-tracking queries (EF Core) — Microsoft Learn, 15 Mar 2023
  9. Deferred execution and lazy evaluation — Microsoft Learn, 20 Jul 2015