Skip to main content

Entry .NET Core Interview Questions

Curated Entry-level .NET Core interview questions for developers targeting entry positions. 15 questions available.

Last updated:

.NET Core Interview Questions & Answers

Skip to Questions

Welcome to our comprehensive collection of .NET Core interview questions and answers. This page contains expertly curated interview questions covering all aspects of .NET Core, from fundamental concepts to advanced topics. Whether you're preparing for an entry-level position or a senior role, you'll find questions tailored to your experience level.

Our .NET Core interview questions are designed to help you:

  • Understand core concepts and best practices in .NET Core
  • Prepare for technical interviews at all experience levels
  • Master both theoretical knowledge and practical application
  • Build confidence for your next .NET Core interview

Each question includes detailed answers and explanations to help you understand not just what the answer is, but why it's correct. We cover topics ranging from basic .NET Core concepts to advanced scenarios that you might encounter in senior-level interviews.

Use the filters below to find questions by difficulty level (Entry, Junior, Mid, Senior, Expert) or focus specifically on code challenges. Each question is carefully crafted to reflect real-world interview scenarios you'll encounter at top tech companies, startups, and MNCs.

Questions

15 questions
Q1:

What is inheritance?

Entry

Answer

One class derives behavior from another using 

class Dog : Animal { }


Quick Summary: Inheritance lets a class (child) reuse and extend the behavior of another class (parent). The child inherits all public and protected members — no need to duplicate code. In C#: class Dog : Animal { }. Dog gets Animal's properties and methods automatically. Use it for "is-a" relationships: a Dog IS an Animal. Prefer composition over deep inheritance hierarchies.
Q2:

What is ASP.NET Core and why was it created?

Entry

Answer

ASP.NET Core is a modern, high-performance, cross-platform framework for building web applications and APIs that can run on Windows, Linux, and macOS.

It was created to overcome limitations of the old ASP.NET Framework such as heavy runtime dependency on the full .NET Framework, tight coupling to IIS, poor modularity, and difficulty integrating with modern CI/CD and containerized environments.

ASP.NET Core introduces a lightweight runtime, a fully modular component system, built-in dependency injection, a unified hosting model, and a redesigned request pipeline focused on speed, flexibility, and cloud readiness.

Quick Summary: ASP.NET Core was built as a complete rewrite of classic ASP.NET — cross-platform (runs on Linux/Mac/Windows), open-source, and much faster. The old framework was Windows-only, tightly coupled to IIS, and carried legacy baggage. ASP.NET Core is lean, built around middleware, native dependency injection, and async by default — designed for cloud and containers.
Q3:

Explain the ASP.NET Core hosting model (Host Builder + Kestrel + Startup flow).

Entry

Answer

ASP.NET Core uses a unified Host (Generic Host / Web Host) that wires together configuration, logging, dependency injection, environment, and the HTTP pipeline.

  • The host sets up configuration (appsettings, environment variables, command line, etc.).
  • It constructs the DI container and registers application services.
  • It configures and starts Kestrel as the web server.
  • It builds the middleware pipeline and endpoint routing (MVC, Razor Pages, minimal APIs).

The high-level flow is: Host ? Kestrel ? Middleware pipeline ? MVC / Razor ? View or JSON result. This gives full low-level control over startup and behavior.

Quick Summary: The Generic Host (IHostBuilder) sets up DI, configuration, and logging. WebApplication.CreateBuilder() builds it for web apps. Kestrel (the built-in HTTP server) listens for connections. Program.cs wires everything up — services, middleware pipeline, and the app start. No Startup.cs is required in .NET 6+ with the minimal hosting model.
Q4:

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

Entry

Answer

Kestrel is the built-in, cross-platform, high-performance web server for ASP.NET Core.

It is optimized for asynchronous I/O, low memory overhead, and extremely fast request handling, making it suitable for both self-hosted scenarios and running behind reverse proxies such as Nginx, Apache, or IIS.

ASP.NET Core uses Kestrel because it delivers excellent throughput, works on all supported platforms, integrates deeply with the middleware pipeline, and gives developers full control over how requests are processed.

Quick Summary: Kestrel is ASP.NET Core's built-in, cross-platform HTTP server — fast, lightweight, and runs on any OS without IIS. In production, it's typically placed behind a reverse proxy (nginx, IIS) for TLS termination and load balancing. Kestrel handles the raw HTTP connections; the proxy handles the internet-facing concerns.
Q5:

Explain Middleware and the purpose of the ASP.NET Core Request Pipeline.

Entry

Answer

Middleware are components that process HTTP requests and responses in a sequence known as the request pipeline.

  • Each middleware can inspect or modify the incoming request.
  • It may call the next middleware in the pipeline or short-circuit and generate a response.
  • On the way back, it can also modify the outgoing response.

The pipeline is used to implement cross-cutting concerns such as authentication, logging, routing, static file handling, CORS, and endpoint execution. This model replaces the older HTTP modules/handlers, offering a more flexible and composable design.

Quick Summary: Middleware are components that form the request pipeline — each one receives the request, does work, then calls the next. Authentication, routing, exception handling, response compression all work this way. Each middleware is added in Program.cs via app.Use*() methods. The pipeline runs in order on request, and reverse on response.
Q6:

Why does the order of middleware matter so much?

Entry

Answer

Middleware executes in the exact order in which it is registered. Because each middleware can decide whether to pass control to the next component, incorrect ordering can break critical behaviors.

For example:

  • Exception-handling middleware must be early in the pipeline to catch downstream errors.
  • Authentication must run before authorization and MVC.
  • Static file middleware should run before MVC to avoid unnecessary controller execution.

ASP.NET Core does not automatically correct the order, so developers are responsible for composing the pipeline correctly.

Quick Summary: Each middleware wraps the next one in the pipeline. If authentication middleware comes after routing, unauthenticated requests still hit the router. If static files middleware comes after routing, static files would fail to serve. Wrong order causes subtle bugs: put exception handling first, then HSTS, then routing, then authentication, then authorization.
Q7:

What is Dependency Injection in ASP.NET Core and why is it built-in?

Entry

Answer

Dependency Injection (DI) in ASP.NET Core is the built-in mechanism for constructing and wiring application services.

The framework provides a first-class DI container that:

  • Creates and manages service lifetimes.
  • Resolves dependencies for controllers, Razor Pages, middleware, and other components.
  • Encourages testable, loosely coupled code.

Having DI built-in removes the need for static helpers or service locators and standardizes how dependencies are managed across the whole stack.

Quick Summary: DI is built into ASP.NET Core because it's essential for testability, loose coupling, and lifecycle management. Instead of services creating their dependencies (new DbContext()), ASP.NET Core injects them. The DI container manages object lifetimes and wires everything together. You register services in Program.cs and request them via constructor parameters.
Q8:

Explain the three DI lifetimes (Transient, Scoped, Singleton).

Entry

Answer

ASP.NET Core's DI container supports three main lifetimes:

  • Transient – A new instance is created every time it is requested. Best for lightweight, stateless services.
  • Scoped – One instance per HTTP request. Ideal for services that work with per-request data such as unit-of-work or context services.
  • Singleton – A single instance is created and shared for the lifetime of the application. Must be thread-safe and used carefully around shared state.

Choosing the wrong lifetime can lead to concurrency bugs, memory leaks, or stale data.

Quick Summary: Transient: new instance created every time the service is requested — for lightweight, stateless services. Scoped: one instance per HTTP request — for DbContext and request-specific services. Singleton: one instance for the app lifetime — for caches, config wrappers, and truly shared services. Injecting a Scoped service into a Singleton causes a captive dependency bug.
Q9:

What is Configuration in ASP.NET Core and how does it work?

Entry

Answer

ASP.NET Core uses a flexible, layered configuration system where multiple providers are combined to produce the final configuration.

Common sources include:

  • appsettings.json and appsettings.{Environment}.json
  • Environment variables
  • Command-line arguments
  • User Secrets and Azure Key Vault
  • In-memory configuration

Later providers override earlier ones, enabling environment-specific overrides and secure storage of secrets. Configuration values can be bound directly to strongly typed options classes.

Quick Summary: ASP.NET Core's configuration system reads from layered sources: appsettings.json → appsettings.{Environment}.json → environment variables → command-line args → secrets. Later sources override earlier ones. Access via IConfiguration["Section:Key"] or bind entire sections to strongly-typed options classes with IOptions.
Q10:

What is the purpose of IOptions, IOptionsSnapshot, and IOptionsMonitor?

Entry

Answer

These abstractions implement the Options pattern for working with configuration-bound classes.

  • IOptions<T> – A singleton snapshot of configuration, read once at startup.
  • IOptionsSnapshot<T> – A scoped snapshot that is recalculated per request; useful for web apps where config might change between requests.
  • IOptionsMonitor<T> – Supports change notifications and is ideal for long-lived components that need to react to configuration changes at runtime.

They allow strongly typed configuration without scattering configuration reads throughout the codebase.

Quick Summary: IOptions: reads config once at startup — singleton, doesn't pick up changes after app starts. IOptionsSnapshot: reads config per request — picks up changes between requests. IOptionsMonitor: reads config and reacts to changes in real-time via OnChange callback — ideal for configs that need live updates without restart.
Q11:

What is Routing in ASP.NET Core?

Entry

Answer

Routing maps incoming HTTP requests (URL + HTTP method) to application endpoints such as controllers, actions, Razor Pages, or minimal APIs.

ASP.NET Core uses Endpoint Routing, which matches routes early in the pipeline, attaches metadata (like authorization policies), and then later executes the matched endpoint. It supports route templates, constraints, defaults, and custom route patterns.

Quick Summary: Routing maps incoming HTTP requests to handler endpoints (controller actions, Razor Pages, minimal API handlers). ASP.NET Core uses endpoint routing: route matching and endpoint execution are separate phases. Routes are defined via attribute routing ([Route], [HttpGet]) or convention-based routing. Route templates ({controller}/{action}/{id?}) define the URL pattern.
Q12:

Compare Conventional Routing vs Attribute Routing.

Entry

Answer

Conventional routing defines route patterns centrally (e.g., {controller}/{action}/{id?}), which are then applied to many controllers and actions following a naming convention. It is useful for large apps with predictable URL structures.

Attribute routing defines routes directly on controllers and actions via attributes such as [Route], [HttpGet], etc. It is more expressive and better suited for APIs or scenarios where each endpoint may have unique or non-standard URL patterns.

Quick Summary: Conventional routing defines a central route template: app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"). Attribute routing puts routes directly on controllers/actions: [Route("api/users")]. Attribute routing is more explicit and predictable for APIs. Conventional routing is simpler for traditional MVC apps with many similar routes.
Q13:

What is Model Binding?

Entry

Answer

Model binding is the process of converting HTTP request data into .NET objects that are used as parameters to controller actions or Razor Page handlers.

It pulls values from sources like route data, query strings, form fields, headers, and cookies, then converts and populates complex types, collections, and nested objects. This lets you work with rich, strongly typed parameters instead of manually parsing the request.

Quick Summary: Model binding automatically maps HTTP request data (form fields, route values, query strings, JSON body) to method parameters and model properties. When an action receives a CreateUserRequest parameter, ASP.NET Core reads the request body and populates every matching property automatically. No manual request parsing needed.
Q14:

What is Model Validation and how does it work?

Entry

Answer

Model validation runs immediately after model binding and before the action method executes.

  • Validation rules are typically expressed via data annotations (e.g., [Required], [Range]).
  • Errors are added to ModelState.
  • Controllers or Razor Pages check ModelState.IsValid to decide whether to continue or return validation errors.

Validation can also be implemented via IValidatableObject or custom validators, ensuring that only valid data reaches business logic.

Quick Summary: Model validation checks that bound model properties satisfy their data annotation constraints ([Required], [MaxLength], [EmailAddress], [Range]). After binding, ASP.NET Core populates ModelState — if invalid, ModelState.IsValid is false and you return a 400 response. FluentValidation is a popular alternative to data annotations for complex rules.
Q15:

What are Filters and why are they important?

Entry

Answer

Filters are extensibility points in the MVC and Razor Pages pipeline that allow code to run before or after critical stages.

Types of filters include:

  • Authorization filters
  • Resource filters
  • Action filters
  • Exception filters
  • Result filters

They are ideal for cross-cutting concerns like logging, caching, auditing, authorization, and exception handling without polluting controller or page logic.

Quick Summary: Filters run at specific points in the MVC pipeline — before/after model binding, action execution, result execution, and exception handling. Types: Authorization (runs first), Resource, Action, Result, Exception. Filters are cleaner than middleware for MVC-specific cross-cutting concerns like logging action parameters or adding response headers per action.

Curated Sets for .NET Core

No curated sets yet. Group questions into collections from the admin panel to feature them here.

Ready to level up? Start Practice