.Net interview questions and answers
.NET Interview Questions
🔰 Basic .NET Interview Questions
Q1.What is the .NET Framework?
Q2.What is the CLR (Common Language
Runtime)?
Q3.What is the CTS (Common Type
System)?
Q4.What is the difference between
.NET Framework, .NET Core, and .NET 5/6/7?
Q5.What are value types and reference
types in .NET?
Q6.What is the difference between an
abstract class and an interface?
Q7.What are assemblies and
namespaces?
Q8.What is a managed and unmanaged
code?
Q9.What is JIT Compilation in .NET?
Q10.What is a delegate? What is the
difference between delegate and event?
Q11. What is an EXE and a DLL?
Q12. What
is the difference between int and Int32?
💡 C# Specific Questions
Useful if you are applying for a .NET
developer position using C#:
Q1.What is the difference between
const, readonly, and static?
Q2.What is boxing and unboxing?
Q3.What is the use of var, dynamic,
and object types?
Q4.Explain the use of async and await
in C#.
Q5.What is the difference between ==
and Equals() in C#?
Q6.What are access modifiers in C#?
Q7.What is the difference between
override and new keywords in C#?
Q8.What is a nullable type?
Q9.What is LINQ in C#?
Q10.What are extension methods?
🧠 Advanced .NET Interview Questions
For mid to senior-level positions:
Q1.What are the main features of .NET
Core/.NET 6/7?
Q2.What is dependency injection in
.NET?
Q3.What are Middleware and the request
pipeline in ASP.NET Core?
Q4.How do you implement logging in
.NET Core?
Q5.What is garbage collection and how
does it work in .NET?
Q6.How do you implement a custom exception
filter in ASP.NET Core?
Q7.Explain async/await and the Task
Parallel Library (TPL).
Q8.What is the difference between
Task and Thread?
Q9.What is the difference between
Transient, Scoped, and Singleton services in DI?
Q10.What is SignalR and where is it
used?
🧩 ASP.NET / ASP.NET Core Questions
Q1.What is the difference between
ASP.NET MVC and ASP.NET Core?
Q2.What are Tag Helpers in ASP.NET
Core?
Q3.What is ViewState? Does ASP.NET
Core use it?
Q4.What is Razor Pages? How is it
different from MVC?
Q5.How do you handle session and
cookies in ASP.NET Core?
Q6.What is the role of
appsettings.json in ASP.NET Core?
Q7.How do you secure a web API in
ASP.NET Core?
Q8.How is routing handled in ASP.NET
Core?
Q9.What are Filters in ASP.NET Core?
Q10.How do you consume Web APIs in
.NET applications?
Q11. What
is the order of the events in a page life cycle?
Q12. What
is a garbage collector?
Q13. What
is caching?
Q14. Explain
MVC.
Q15. What
is IIS?
Q16. What
is Kestrel?
Q17. What
is the purpose of the Startup class?
Q18. What
is NuGet package manager?
Q19. What
is the MVC pattern?
Q20. What
is Entity Framework?
Q21. What
is a RESTful Web Service or a Web API?
Q22. What
is routing, and how can you define routes in ASP.NET Core?
Q23. Explain
the concept of middleware in ASP.NET Core?
Q24. What
is a cookie?
Q25. Explain
how dependency injection works in ASP.NET Core?
Q26. What
is dependency injection?
Q27. What
are the different types that implement the IActionResult interface?
🛠️ Entity Framework / Database Related
Q1.What is Entity Framework Core?
Q2.What is the difference between EF
Core and EF 6?
Q3.What are migrations in EF Core?
Q4.How do you configure relationships
(one-to-many, many-to-many)?
Q5.What is Lazy Loading, Eager
Loading, and Explicit Loading?
Q6.How to handle concurrency in EF
Core?
Q7.What is the repository pattern?
Q8.How to execute raw SQL queries
using EF Core?
💼 Behavioral/Scenario-Based Questions
Describe a challenging bug you fixed
in a .NET application.
Q1.How do you manage version control
in .NET projects?
Q2.Explain your approach to unit
testing in .NET.
Q3.Have you worked with microservices
in .NET?
Q4.How do you ensure performance and
scalability in .NET applications?
🔰 Basic API Interview Questions
1.
What
is an API?
2.
What
is REST API?
3.
What
are the HTTP methods supported in REST?
4.
What
is the difference between PUT and POST?
5.
What
are the main components of an HTTP request?
6.
What
is the status code 200, 201, 400, 401, 403, 404, 500?
7.
What
is the difference between REST and SOAP APIs?
8.
What
is a URI and what is a URL?
9.
What
is JSON and why is it used in APIs?
10.
What
is Idempotency in REST?
🧠 ASP.NET Core Web API Specific
Questions
1.
How
do you create a Web API in ASP.NET Core?
2.
What
is the use of [ApiController] attribute?
3.
What
is routing in ASP.NET Core Web API?
4.
How
do you return different status codes from a controller?
5.
What
is the difference between IActionResult and ActionResult<T>?
6.
How
do you handle model validation in Web API?
7.
How
do you bind complex types in query string and body?
8.
What
is middleware in ASP.NET Core?
9.
What
are Filters (Authorization, Resource, Exception)?
10.
What
is dependency injection and how is it used in Web API?
🔐 Authentication & Authorization in
APIs
1.
What
is the difference between Authentication and Authorization?
2.
How
do you secure a Web API in ASP.NET Core?
3.
What
is JWT (JSON Web Token)?
4.
How
does token-based authentication work?
5.
What
is OAuth2 and OpenID Connect?
6.
How
do you implement Role-Based Authorization?
7.
How
do you configure CORS in ASP.NET Core Web API?
8.
What
is API key authentication?
9.
How
to handle sensitive data in API headers or body?
10.
What
is HTTPS and why is it required for APIs?
🛠️ Advanced/API Design Questions
1.
How
do you version a Web API?
2.
What
are best practices for RESTful API design?
3.
How
do you handle exception handling in Web API?
4.
What
is Swagger / OpenAPI?
5.
How
do you document a Web API?
6.
What
is HATEOAS in REST API?
7.
How
do you implement rate limiting in Web API?
8.
How
do you unit test an API controller?
9.
How
do you handle large file uploads in an API?
10.
How
do you cache API responses in ASP.NET Core?
🧪 Scenario-Based / Real-World Questions
1.
How
would you handle version changes in a public API without breaking existing
clients?
2.
How
do you handle multiple file uploads securely?
3.
A
client reports a 401 error; how do you debug it?
4.
How
do you log and monitor API requests and performance?
5.
How
do you design an API for a mobile application with limited connectivity?
6.
How
would you implement search/filter/sort/pagination in an API?
7.
What
if two users update the same resource simultaneously?
8.
How
do you protect an API from brute-force attacks or misuse?
9.
How
would you migrate from basic authentication to JWT?
10.
How
do you deploy and scale a high-traffic Web API?
SQL Interview Questions
🔰 Basic SQL Interview Questions (For
Freshers)
1.
What
is SQL?
2.
What
is the difference between SQL and MySQL/SQL Server/Oracle?
3.
What
are the different types of SQL commands?
(DDL, DML, DCL, TCL, DQL)
4.
What
is the difference between DELETE, TRUNCATE, and DROP?
5.
What
is a primary key? Can a table have multiple primary keys?
6.
What
is a foreign key?
7.
What
is the difference between WHERE and HAVING?
8.
What
is a join? Name the types of joins.
9.
What
is normalization? Explain 1NF, 2NF, 3NF.
10.
What
is a constraint in SQL? Name a few.
💡 Intermediate SQL Interview Questions
1.
What
is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER
JOIN?
2.
What
is a GROUP BY clause?
3.
What
is the use of ORDER BY clause?
4.
What
is a subquery? Explain correlated vs non-correlated subqueries.
5.
What
are indexes in SQL? How do they improve performance?
6.
What
is the difference between UNION and UNION ALL?
7.
What
is a view? How is it different from a table?
8.
What
is a stored procedure? How is it different from a function?
9.
What
is the difference between IS NULL, = NULL, and IS NOT NULL?
10.
What
is a trigger? When would you use one?
🧠 Advanced SQL Interview Questions
1.
How
do you find the second highest salary in a table?
2.
What
is a CTE (Common Table Expression)?
3.
How
would you optimize a slow-running query?
4.
What
is window function in SQL? Explain ROW_NUMBER(), RANK(), DENSE_RANK(), LEAD(),
LAG()
5.
What
is the difference between clustered and non-clustered index?
6.
How
do you handle duplicates in SQL?
7.
What
is a transaction? What are ACID properties?
8.
How
do you implement pagination in SQL?
9.
How
do you perform pivoting and unpivoting in SQL?
10.
What
are temporary tables and table variables?
🛠️ SQL Query Scenarios
1.
Write
a query to fetch duplicate records in a table.
2.
Write
a query to get the department with the highest number of employees.
3.
Write
a query to find employees who joined in the last 6 months.
4.
Write
a query to find the cumulative salary per department.
5.
Write
a query to transpose rows into columns.
6.
Write
a query to count the number of employees per department having more than 5
employees.
7.
Write
a query to get top 3 records per group (e.g., top 3 salaries per department).
8.
Write
a query to delete duplicate rows from a table.
9.
Write
a query to update a record based on a join.
10.
Write
a query to get all managers who don’t have any subordinates.
🔐 SQL Security and Admin
1.
What
are roles and permissions in SQL Server?
2.
What
is SQL injection? How can you prevent it?
3.
What
is the difference between GRANT, REVOKE, and DENY?
4.
How
do you take a backup and restore a database?
5.
What
is the difference between a login and a user in SQL Server?
ASP.NET Core Interview Questions
🔰 Basic ASP.NET Core Interview Questions
1.
What
is ASP.NET Core?
2.
How
is ASP.NET Core different from ASP.NET MVC?
3.
What
is the role of the Startup.cs file?
4.
What
is the Program.cs file used for in .NET 6/7/8?
5.
What
is Middleware in ASP.NET Core?
6.
What
is the purpose of the appsettings.json file?
7.
What
is Dependency Injection? How is it implemented in ASP.NET Core?
8.
What
is the use of the [ApiController] attribute?
9.
What
is Kestrel in ASP.NET Core?
10.
What
is the difference between AddSingleton, AddScoped, and AddTransient services?
🧠
Intermediate ASP.NET Core Questions
1.
How
is Routing handled in ASP.NET Core?
2.
What
are Action Filters and how are they used?
3.
What
is Model Binding and Model Validation?
4.
How
do you return custom HTTP status codes in ASP.NET Core?
5.
What
is the use of IConfiguration and IOptions interfaces?
6.
How
do you manage environments (Development, Staging, Production) in ASP.NET Core?
7.
How
do you implement Logging in ASP.NET Core?
8.
How
do you create and use Middleware?
9.
What
are Tag Helpers and View Components?
10.
What
is Razor Pages and how is it different from MVC?
🔐 Security in ASP.NET Core
1.
How
do you implement authentication in ASP.NET Core?
2.
What
is JWT (JSON Web Token) authentication?
3.
How
do you implement role-based and policy-based authorization?
4.
How
do you use Identity in ASP.NET Core?
5.
What
is CORS and how do you configure it?
6.
How
do you secure sensitive data like connection strings or keys?
7.
What
are anti-forgery tokens and how do you use them?
8.
How
can you implement OAuth2 and OpenID Connect in ASP.NET Core?
🧪
Web API Specific Questions
1.
How
do you create a Web API in ASP.NET Core?
2.
What
is the difference between IActionResult and ActionResult<T>?
3.
How
do you implement versioning in Web APIs?
4.
How
do you validate a request body in Web API?
5.
What
is Swagger and how do you implement it in ASP.NET Core?
6.
How
do you upload files in ASP.NET Core Web API?
7.
How
do you handle exceptions globally in Web API?
8.
What
is rate limiting and how do you implement it?
🛠️ Advanced ASP.NET Core Interview Questions
1.
How
do you implement custom Middleware?
2.
What
are Hosted Services in ASP.NET Core?
3.
What
is the difference between synchronous and asynchronous controllers?
4.
How
do you cache data in ASP.NET Core (in-memory, response caching, distributed
caching)?
5.
How
do you work with gRPC in ASP.NET Core?
6.
How
do you deploy an ASP.NET Core app to IIS, Azure, or Docker?
7.
How
do you implement health checks and diagnostics in ASP.NET Core?
8.
How
is configuration handled in ASP.NET Core (JSON, Environment Variables, User
Secrets)?
9.
What
are Minimal APIs in .NET 6+?
10.
What’s
the difference between Minimal API and MVC Controller-based API?
🧩
Scenario-Based Questions
- How would you secure a public Web API exposed to
third-party clients?
- How do you handle multiple environments in CI/CD
pipelines for ASP.NET Core apps?
- How do you integrate Entity Framework Core in an
ASP.NET Core application?
- How would you create a multi-tenant application in
ASP.NET Core?
- If a user logs out, how do you invalidate their JWT
token?