1. What is MVC?

MVC stands for Model-View-Controller. It is a design pattern that splits an application into three parts so each part has one job. This makes the code easier to read, test and maintain, and lets several developers work on different parts at once. ASP.NET Core MVC is Microsoft's framework for building web applications with this pattern.

Key points

  • Model: the data and business rules (for example a Student or Order class).
  • View: what the user sees, written in HTML with Razor (.cshtml files).
  • Controller: receives the browser request, works with the model, and chooses the view to return.
  • Separation of concerns: each part can change without breaking the others.

Example: The flow of a request

Concept
Browser  -->  Controller  -->  Model (data)
                  |
                  v
               View (HTML)  -->  Browser
Show explanation

1. The user opens a URL. 2. The controller action runs. 3. The action asks the model for data. 4. The action passes the data to a view. 5. The view builds HTML and it is sent back to the browser.