Top 50 ASP.NET Core Interview Questions and Answers by OM IT Trainings Institute

interview

Introduction

Preparing for an ASP.NET Core interview? This Top 50 ASP.NET Core Interview Questions & Answers guide by OM IT Trainings Institute is designed to help freshers and experienced candidates master the fundamentals and advanced concepts of ASP.NET Core. Whether you’re exploring middleware, dependency injection, MVC, API development, or real-world enterprise applications, this guide will strengthen your technical knowledge and boost your interview confidence.

Let’s dive into the most important ASP.NET Core interview questions and answers to help you succeed in your next interview.

ASP.NET Core Interview Questions & Answers

Preparing for an ASP.NET Core interview? This expertly crafted guide by OM IT Trainings Institute brings you the most commonly asked ASP.NET Core Interview Questions and Answers, designed to help both beginners and experienced developers strengthen their skills.

  • ASP.NET Core Interview Questions and Answers for Freshers

  • ASP.NET Core Interview Questions and Answers for Experienced

1. What is ASP.NET Core?

Answer: ASP.NET Core is an open-source, cross-platform framework used to build modern web apps, APIs, and cloud-based applications. It is fast, modular, lightweight, and runs on Windows, Linux, and macOS.

2. How does .NET Core differ from the traditional .NET Framework?

Answer: NET Core and the traditional .NET Framework are both development platforms from Microsoft, but they serve different purposes and application environments.

3. What is Middleware in ASP.NET Core?

Answer: Middleware is a software components in the request pipeline that handle requests and responses.

Example: Authentication, Logging, Routing, Exception handling.

4. What is Dependency Injection (DI)?

DI is a design pattern where dependent objects are supplied rather than created in a class.
ASP.NET Core has built-in DI for controllers, services, and middleware.

5. What is Startup.cs used for?

Answer:

    • Startup.cs configures the app, including services and middleware:

      • ConfigureServices() — 

      • Configure() — Configure middleware pipeline

ASP.NET Core Training

Learn via our Course

Level Up Your Coding Skills with Expert ASP.NET Core Training in Chandigarh & Mohali!

6. What is Program.cs?

Answer:

Program.cs is the entry point of an ASP.NET Core app and configures the host and web server.

7. What are Services in ASP.NET Core?

Answer: Services are classes that contain business logic and are injected using DI.

8. Why did Microsoft create .NET Core when .NET Framework already existed?

Answer: Microsoft created .NET Core to address the limitations of the traditional .NET Framework and to modernize the development ecosystem for evolving technology trends.

9. What is Routing?

Answer: Routing maps incoming requests to controller actions or endpoints.

10. What problem does .NET Core solve that the .NET Framework couldn’t?

Answer: NET Core was developed to address several limitations of the traditional .NET Framework, especially around flexibility, performance, and modern deployment needs.

11. What is Model Binding?

Answer: Model Binding converts HTTP request data (form, query, JSON) into C# objects.

12. What is Model Validation?

Answer: Checks data rules using attributes like: [Required], [StringLength], [EmailAddress]

13. What is Entity Framework Core?

Answer: EF Core is an ORM that helps interact with databases using C# instead of SQL.

14. Migration in EF Core?

Answer: Migrations keep the database schema and model synchronised.
Commands: Add-Migration
Update-Database

15. What is Kestrel?

Answer: Kestrel is the default cross-platform web server for ASP.NET Core apps.

16. What is WebHostBuilder?

Answer: It configures and builds the web host environment for the application.

17. What is Configuration in ASP.NET Core?

Answer: Configuration reads settings from:

  • appsettings.json

  • environment variables

  • secret manager

  • command-line args

18. What is appsettings.json?

Answer: A JSON file for application configuration data, replacing web.config.

19. What is Logging in ASP.NET Core?

Answer: Framework supports logging providers like Console, Debug, Azure, Serilog, etc.

20. What is Authentication vs Authorisation?

Answer: Authentication is the process of verifying a user’s identity — confirming who they are. It typically involves usernames, passwords, biometrics, or login tokens.

21. Role-based Authorization?

Answer: Restricts access using [Authorise (Roles = "Admin")].

22. What is .NET Core CLI?

Answer: Command-line tools to build, run, and publish projects:

dotnet new
dotnet build
dotnet run
dotnet publish

23. What is REST API?

Answer: REST API follows HTTP principles to send/receive data in standard formats like JSON.

24. What is JSON Serialization?

Answer: Converts C# objects to JSON & vice-versa using System.Text.Json.

25. What is Swagger?

Answer: Swagger (OpenAPI) automatically generates API documentation and test UI.

26. What is CORS?

Answer: CORS allows or restricts requests from different domains.

27. What are Filters in MVC?

Answer: Filters execute before/after actions — like logging, auth, caching.
Types: Authorisation, Action, Resource, Exception, Result filters.

28. What is SignalR?

Answer: SignalR provides real-time communication (chat apps, dashboards, live updates).

29. What is gRPC?

Answer: A high-performance RPC framework used for microservices and faster than REST.

30. Can authentication exist without authorization?

Answer: Yes. A system can verify who you are (authentication) without giving you access to specific resources. Authorisation always requires authentication first.

ASP.NET Core Interview Questions and Answers for Experienced

31. Explain the ASP.NET Core request processing pipeline and how middleware works.

Answer: ASP.NET Core uses a pipeline-based request model. Each middleware can:

  • Process the request

  • Pass it to the next middleware (next())

  • Short-circuit the pipeline

  • Modify the response on the way back

Middleware follows chain-of-responsibility pattern and is configured in Program.cs using Use, Run, and Map.

32. How do you implement Clean Architecture in ASP.NET Core?

Answer: Clean Architecture separates concerns into layers:

  • Domain Layer — Entities, value objects, business rules

  • Application Layer — Use cases, interfaces, DTOs

  • Infrastructure Layer — DB, EF Core, external services

  • Presentation Layer — Controllers/UI

Benefits: Maintainability, testability, independent business logic, and easy tech upgrades.

33. How does Dependency Injection work internally in ASP.NET Core?

Answer: ASP.NET Core uses a built-in IoC container (ServiceProvider) to:

  • Register services (Transient, Scoped, Singleton)

  • Resolve dependencies at runtime

  • Manage object lifetimes

It uses constructor injection primarily. Reflection + expression tree compilation improves speed.

34. Explain the difference between AddTransient, AddScoped, and AddSingleton.

Answer:

In ASP.NET Core dependency injection, services are registered with different lifetimes, which determine how long an object instance is maintained.

  • AddTransient creates a new instance every time the service is requested.
    It’s best for lightweight, stateless services such as helper classes or business rules. Since each request gets a fresh object, it avoids shared-state issues.

  • AddScoped creates one instance per HTTP request/connection.
    This means all components within a single web request share the same instance. It’s ideal for services like repository layers or Entity Framework DbContext, where you need consistency across a single request but don’t want the instance to persist beyond it.

  • AddSingleton creates a single instance for the entire application lifetime.
    The same instance is reused across all requests and users. It’s suitable for services that hold application-wide data, configuration, or caching — as long as they are thread-safe. Once created, it stays until the app restarts.

35. How do you maintain state in ASP.NET Core since it’s stateless?

Answer:

  • appsettings.json

  • Configuration sources:
  • Environment variables

  • User secrets

  • Command line

  • Azure Key Vault

IOptions<T> / IOptionsSnapshot / IOptionsMonitor
Used to map strongly-typed config settings.

36. What is the difference between Authentication and Authorisation in ASP.NET Core?

Answer:

  • Authentication: Validate identity → who you are

  • Authorization: Determine access → what you can do

ASP.NET Core supports JWT, Cookies, OAuth, OpenID Connect, Identity Server.

37. What is ASP.NET Identity and how is it different from JWT authentication?

Answer: ASP.NET Identity is a complete authentication and user management framework built into ASP.NET Core.
It provides features like user registration, login, password hashing, role management, email confirmation, MFA, and secure cookie-based authentication. Identity manages users and authentication state inside the application using server-side cookies and database-stored identity info.

JWT (JSON Web Token) authentication, on the other hand, is a token-based, stateless authentication mechanism. After successful login, the server issues a signed token that the client sends with each request. The server doesn’t maintain session state; it simply validates the token. JWT is ideal for APIs, microservices, mobile apps, and distributed environments where scalability matters.

In short, ASP.NET Identity is a full user and membership system, while JWT is a stateless authentication method often used with APIs. You can even combine them — using ASP.NET Identity for user management and JWT for issuing authentication tokens to clients.

38. How do you handle global exception logging?

Answer: Use UseExceptionHandler() middleware + logging: app.UseExceptionHandler("/error"); app.UseHsts();

Or implement custom middleware and integrate with Serilog / ELK / Seq / Application Insights.

39. Explain Filters in MVC and their types.

Answer:

Used to run logic:

  • Before/after action

  • Before/after result

  • On exception

  • On resource execution
    Types: Authorisation, Resource, Action, Exception, Result filters

40. What is gRPC in .NET and when would you use it?

Answer:

gRPC = high-performance RPC for microservices.
Uses HTTP/2 + protobuf, ideal for:

  • Low-latency communication

  • Real-time systems

  • IoT, distributed services

Faster than REST in many cases.

41. Difference between IActionResult and ActionResult

Answer:

IActionResult = generic response
ActionResult<T> = strongly typed + action response flexibility

42. Explain EF Core Change Tracking mechanism.

Answer: EF Core tracks entity states:

  • Added

  • Modified

  • Unchanged

  • Deleted

  • Detached

Uses DbContext ChangeTracker; can disable for performance:

43. How do you optimise EF Core performance?

Answer:

    • Batch commands

    • Use AsNoTracking()
    • Compile queries

    • Use pagination

    • Indexing

    • Keep DbContext life short

44. What is distributed caching?

Answer: Stores cache across servers; used in cloud apps, load-balanced systems.
Providers:

  • Redis

  • SQL Server

  • NCache

  • MemoryDistributedCache

45. Explain Horizontal vs Vertical Scaling in ASP.NET Core apps.

Answer: Vertical scaling means improving the capacity of a single server by adding more hardware resources — like increasing CPU, RAM, or storage. In an ASP.NET Core environment, this means the same application runs on a more powerful machine. It’s simple to implement but has physical limits and creates a single point of failure — if the server goes down, the app stops.

Horizontal scaling means adding more application instances or servers to distribute traffic. Instead of one powerful server, multiple servers run the ASP.NET Core app behind a load balancer. This approach supports better fault tolerance, high availability, and near-unlimited growth. It’s used in cloud environments like Azure App Service, Kubernetes, and Docker.

46. Explain Rate Limiting in .NET 7/8

Answer: Built-in middleware for throttling API requests.
Prevents:

  • DDOS

  • Abuse

  • Overloading APIs
    Supports fixed, sliding, token bucket algorithms.

47. How do you secure APIs in production?

Answer:

    • JWT/OAuth

    • HTTPS + HSTS
    • Rate limiting

    • Input validation

    • CORS policy

    • API gateway

    • Secrets vault (Azure, AWS)

    • Logging & threat monitoring

48. Explain CQRS in ASP.NET Core

Answer: Separates read and write models for scalability:

  • Commands → modify data

  • Queries → fetch data

Often used with MediatR library.

49. How do you containerise and deploy ASP.NET Core apps?

Answer:

Using Docker:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 COPY /publish . ENTRYPOINT ["dotnet", "App.dll"]

Deployment targets:

  • Docker  Kubernetes

  • Azure Web Apps

  • AWS Elastic Beanstalk

  • Linux servers (Nginx + Kestrel)

50. How do you implement Microservices in ASP.NET Core and what patterns do you use?

Answer: Microservices in ASP.NET Core involve building small, independently deployable services that communicate using lightweight protocols like HTTP, gRPC, or messaging systems such as RabbitMQ / Kafka / Azure Service Bus.

Scroll to Top

    Download Syllabus

      Book Your Seat