Ticker

6/recent/ticker-posts

💻 .NET Interview Preparation – 24 Must-Know Questions with Answers

💻 .NET Interview Preparation – 24 Must-Know Questions with Answers

1️⃣ What is .NET Core and how is it different from .NET Framework?

Answer:
.NET Core is a cross-platform, open-source framework that runs on Windows, Linux, and macOS.
.NET Framework is Windows-only and mainly used for legacy applications.


2️⃣ How do you create a Web API project in .NET Core?

Answer:
Use Visual Studio or CLI:
dotnet new webapi -n ProjectName


3️⃣ What is Middleware in .NET Core?

Answer:
Middleware components handle HTTP requests and responses in a pipeline (e.g., authentication, logging).


4️⃣ What is Dependency Injection (DI)?

Answer:
DI is a design pattern used to inject dependencies into classes, improving flexibility and testing.


5️⃣ How do you configure appsettings.json?

Answer:
Use builder.Configuration["Key"] or bind values using IConfiguration or Options pattern.


6️⃣ Difference between ActionResult and ActionResult<T>?

Answer:
ActionResult<T> allows returning typed responses with HTTP status codes.


7️⃣ How do you enable Swagger?

Answer:
Install Swagger package and use:
builder.Services.AddSwaggerGen();


8️⃣ What are Transient, Scoped, Singleton lifetimes?

Answer:

  • Transient: New instance every request
  • Scoped: One instance per request
  • Singleton: One instance for application lifetime

9️⃣ How do you implement logging?

Answer:
Use ILogger interface with built-in logging providers.


🔟 What are Filters in ASP.NET Core?

Answer:
Filters run before or after controller actions (e.g., authorization, exception filters).


1️⃣1️⃣ How do you implement global exception handling?

Answer:
Use Exception Middleware or UseExceptionHandler().


1️⃣2️⃣ What is Program.cs / Startup.cs?

Answer:
These files configure services and middleware for the application.


1️⃣3️⃣ How is authentication implemented in APIs?

Answer:
Using JWT tokens, Identity, or OAuth authentication.


1️⃣4️⃣ Difference between Kestrel and IIS?

Answer:

  • Kestrel: Lightweight web server
  • IIS: Full-featured Windows web server

1️⃣5️⃣ What are Health Checks?

Answer:
Used to monitor application and service health.


1️⃣6️⃣ What is Circuit Breaker Pattern?

Answer:
Stops repeated failures by blocking calls temporarily.


1️⃣7️⃣ What is IHostedService?

Answer:
Used to run background services.


1️⃣8️⃣ Minimal APIs vs Controllers?

Answer:
Minimal APIs use less code, Controllers provide structured architecture.


1️⃣9️⃣ How do you implement caching?

Answer:
Using:

  • Memory Cache
  • Distributed Cache
  • Response Cache

2️⃣0️⃣ How does EF Core handle migrations?

Answer:
Use commands:
Add-Migration
Update-Database


2️⃣1️⃣ What is gRPC?

Answer:
High-performance RPC framework for microservices communication.


2️⃣2️⃣ How do you containerize .NET API?

Answer:
Using Dockerfile and Docker containers.


2️⃣3️⃣ How do you secure APIs using JWT?

Answer:
Validate JWT tokens in middleware using authentication schemes.


2️⃣4️⃣ What is BackgroundService?

Answer:
Used to run long-running background tasks in .NET applications.


💡 If you're preparing for .NET interviews

I can also create:

  • ✔ Coding Questions with Solutions
  • ✔ Scenario-Based Questions
  • ✔ 5–8 Years Experience Interview Questions
  • ✔ Real Project Interview Questions

Just tell me your experience level (e.g., 2 years / 5 years / 8 years).




Post a Comment

0 Comments