ASP.NET Core is idiomatic C#. Web code favors async I/O, dependency injection, LINQ for data shaping, and records/DTOs for API contracts. If you know Java or Python, C# feels familiar: classes, interfaces, generics, and exceptions.
Patterns you will see everywhere
- POCO classes — plain models and view models without framework base classes
- Interfaces for services —
IUserServiceregistered in DI, injected into controllers - Nullable reference types —
string?signals optional values at compile time - Async all the way —
await _db.Users.ToListAsync()frees threads during database calls
Example: service-shaped class
public interface IGreetingService {
string Greet(string name);
}
public class GreetingService : IGreetingService {
public string Greet(string name) => $"Hello, {name}";
}
Controllers receive IGreetingService via constructor injection—no new in the controller body.
Important interview questions and answers
- Q: Why async in web apps?
A: I/O-bound work (DB, HTTP) should not block thread pool threads—async improves scalability under load. - Q: POCO vs active record?
A: EF Core entities are often POCOs; behavior lives in services, not fat models (team preference varies).
Self-check
- What does DI replace in controller code?
- Why use interfaces for services?