MVC
Separates the model (data), view (UI), and controller (input) into independent components.
Context
The classic architecture for UIs and most web frameworks (ASP.NET MVC, Rails, Spring MVC).
Solution
- Model: data and rules.
- View: render.
- Controller: receives input, calls the model, chooses the view.
public class OrdersController : Controller
{
private readonly IOrderService _svc;
public OrdersController(IOrderService s) => _svc = s;
public async Task<IActionResult> Detail(Guid id)
{
var order = await _svc.GetAsync(id);
return View(order); // ← Razor view receives the model
}
}When NOT to use it
- In SPAs: the backend controller no longer controls the view. Consider MVVM or Backend-for-Frontend.
#architecture #ui