.NET Core Interview Questions for Experienced Developers

.NET Core Interview Questions for Experienced Developers

🧠 Core Concepts & Architecture

1. What is .NET Core, and how is it different from the .NET Framework?
.NET Core (now part of modern .NET) is cross-platform, open-source, and optimized for cloud and microservices, whereas the .NET Framework is Windows-only and more monolithic.

2. Explain the Generic Host in .NET Core.
It provides a common way to configure apps with dependency injection, logging, and configuration for different app types (web, worker services).

3. What is middleware in ASP.NET Core?
Middleware components handle HTTP requests and responses in a pipeline. Each component can process or pass the request to the next.

4. How does the request pipeline work?
Requests flow through middleware in order. Each middleware can handle, modify, or forward the request.


⚙️ Dependency Injection & Services

5. What are the service lifetimes in .NET Core?

  • Transient: Created every time requested
  • Scoped: Created once per request
  • Singleton: Created once for the entire application

6. How does dependency injection improve maintainability?
It reduces tight coupling and makes code easier to test and extend.

7. What is constructor injection vs method injection?
Constructor injection provides dependencies through constructors; method injection passes them into specific methods when needed.


🌐 ASP.NET Core & Web API

8. What is the difference between MVC and Web API?
MVC is used for building web apps with UI, while Web API is used for building RESTful services.

9. What are filters in ASP.NET Core?
Filters run before or after certain stages of request processing (e.g., authorization, action execution).

10. What is model binding?
It maps HTTP request data to action method parameters automatically.

11. How do you handle exceptions globally?
Using middleware or built-in exception handling like UseExceptionHandler.


🗄️ Entity Framework Core

12. What is EF Core?
An ORM that allows interaction with databases using .NET objects.

13. What is DbContext?
It represents a session with the database and is used to query and save data.

14. What are migrations?
They help manage database schema changes over time.

15. What is tracking vs no-tracking?
Tracking keeps changes in memory for updates; no-tracking improves performance for read-only queries.

16. What are eager, lazy, and explicit loading?

  • Eager: Load related data immediately
  • Lazy: Load when accessed
  • Explicit: Load manually when needed

🚀 Performance & Optimization

17. How do you improve performance in .NET Core apps?
Use caching, async programming, minimize allocations, optimize queries, and enable response compression.

18. What is caching in .NET Core?
Storing frequently used data to reduce repeated processing (in-memory or distributed cache).

19. What is asynchronous programming in .NET Core?
Using async and await to avoid blocking threads and improve scalability.


🔐 Security

20. How is authentication handled in ASP.NET Core?
Using middleware like JWT, cookies, or external providers.

21. What is authorization?
It determines what a user is allowed to access.

22. How do you secure APIs?
Use HTTPS, JWT tokens, input validation, and proper authentication mechanisms.


☁️ Microservices & Cloud

23. How does .NET Core support microservices?
Through lightweight services, container support (Docker), and cross-platform capabilities.

24. What is configuration in .NET Core?
It supports multiple sources like JSON files, environment variables, and command-line arguments.

25. What is logging in .NET Core?
Built-in logging framework supports multiple providers like console, file, and cloud services.


🧩 Advanced Topics

26. What is Kestrel?
A cross-platform web server used by ASP.NET Core applications.

27. What is middleware short-circuiting?
When middleware stops further processing and returns a response immediately.

28. What is Health Checks in .NET Core?
Used to monitor application health and dependencies.

29. What is minimal API?
A lightweight way to build APIs with less boilerplate code.

30. How do you handle versioning in APIs?
Using URL versioning, query parameters, or headers.


🧪 Scenario-Based Questions

31. How would you design a scalable .NET Core application?
Use microservices, caching, async processing, and load balancing.

32. How do you troubleshoot memory leaks?
Use profiling tools, analyze object lifetimes, and review dependency usage.

33. How do you handle high traffic in APIs?
Implement caching, rate limiting, and horizontal scaling.

34. How do you manage secrets securely?
Use environment variables, secret managers, or vault services.

35. How do you deploy a .NET Core app?
Using cloud platforms, containers, or traditional hosting environments.


🧠 Pro-Level Discussion Questions

36. When would you choose .NET Core over other frameworks?
When you need performance, cross-platform support, and strong ecosystem tools.

37. What are the trade-offs of using EF Core vs Dapper?
EF Core is easier and feature-rich; Dapper is faster but requires more manual work.

38. How do you implement clean architecture in .NET Core?
Separate concerns into layers like Domain, Application, Infrastructure, and API.

.NET Core Interview Questions with Answers (Experienced)

🧠 Core Concepts & Architecture

1. What is .NET Core, and how is it different from .NET Framework?
.NET Core (now unified into modern .NET) is a cross-platform, open-source framework designed for high performance and cloud-based applications. The .NET Framework is Windows-only and more suited for legacy enterprise apps.

2. What is the Generic Host?
The Generic Host provides a standardized way to configure services like dependency injection, logging, and configuration across different types of applications (web apps, background services, etc.).

3. What is middleware in ASP.NET Core?
Middleware are components that form a request pipeline. Each middleware can handle requests, modify responses, or pass control to the next component.

4. Explain the request pipeline.
Incoming HTTP requests pass through a sequence of middleware components. Each component can process or forward the request, and the response flows back through the same pipeline.


⚙️ Dependency Injection

5. Service lifetimes in .NET Core

  • Transient: New instance every time
  • Scoped: One instance per HTTP request
  • Singleton: One instance for the entire app lifecycle

6. Benefits of dependency injection
It improves code maintainability, testability, and flexibility by reducing tight coupling.

7. Constructor vs Method Injection
Constructor injection is the most common and ensures dependencies are available when the object is created. Method injection provides dependencies only when needed.


🌐 ASP.NET Core & Web API

8. MVC vs Web API
MVC is used for applications with UI (views), while Web API is used to build RESTful services returning data (JSON/XML).

9. What are filters?
Filters allow execution of logic before or after certain stages like authorization, action execution, or exception handling.

10. What is model binding?
It automatically maps HTTP request data (query string, form data, JSON) to action method parameters.

11. Global exception handling
Handled using middleware like UseExceptionHandler or custom exception middleware.


🗄️ Entity Framework Core

12. What is EF Core?
An Object-Relational Mapper (ORM) that lets developers interact with databases using .NET objects instead of SQL.

13. What is DbContext?
It represents a session with the database and is responsible for querying and saving data.

14. What are migrations?
Migrations help evolve the database schema over time without losing data.

15. Tracking vs No-Tracking
Tracking keeps track of entity changes for updates. No-tracking improves performance for read-only queries.

16. Loading types

  • Eager: Loads related data immediately
  • Lazy: Loads data when accessed
  • Explicit: Manually loads related data

🚀 Performance & Optimization

17. Performance improvements
Use caching, async programming, efficient queries, and reduce unnecessary object creation.

18. What is caching?
Storing frequently accessed data in memory or distributed systems to reduce computation or database calls.

19. Async programming
Using async and await to avoid blocking threads, improving scalability and responsiveness.


🔐 Security

20. Authentication in ASP.NET Core
Handled via middleware using JWT tokens, cookies, or external providers like OAuth.

21. Authorization
Defines what resources a user can access after authentication.

22. Securing APIs
Use HTTPS, token-based authentication, input validation, and proper error handling.


☁️ Microservices & Configuration

23. Microservices support
.NET Core supports microservices through lightweight APIs, containerization, and cloud readiness.

24. Configuration system
Supports multiple sources like JSON files, environment variables, and command-line arguments.

25. Logging
Built-in logging supports multiple providers and structured logging.


🧩 Advanced Topics

26. What is Kestrel?
A high-performance, cross-platform web server used by default in ASP.NET Core.

27. Middleware short-circuiting
When middleware stops further processing and directly returns a response.

28. Health Checks
Used to monitor application and dependency health (e.g., database, services).

29. Minimal APIs
A lightweight way to create APIs with minimal configuration and code.

30. API versioning
Implemented via URL (/v1/), query parameters, or headers.


🧪 Scenario-Based Answers

31. Designing scalable apps
Use microservices, caching, async processing, load balancing, and database optimization.

32. Troubleshooting memory leaks
Use profiling tools, monitor object lifetimes, and avoid unnecessary static references.

33. Handling high traffic
Implement caching, rate limiting, load balancing, and horizontal scaling.

34. Managing secrets
Use environment variables or secure vault services.

35. Deployment
Deploy using cloud platforms, Docker containers, or CI/CD pipelines.


🧠 Pro-Level Answers

36. When to choose .NET Core?
When building high-performance, scalable, cross-platform, or cloud-native applications.

37. EF Core vs Dapper
EF Core is feature-rich and easier to use; Dapper is faster and more lightweight but requires manual SQL.

38. Clean architecture
Organize code into layers like Domain, Application, Infrastructure, and Presentation to improve maintainability and scalability.