ASP.NET Core Razor Pages are great for simple websites. For more complex websites, it would be better to have a more formal structure to manage that complexity.
This is where the Model-View-Controller design pattern is useful. It uses technologiessimilar to Razor Pages, but allows a cleaner separation between concerns, as shown in the following list:
- Models: A folder that contains classes that represent the data used in the websites.
- Views: A folder that contains Razor files, that is, the
.cshtml
files, that convert models into HTML pages. - Controllers: A folder that contains classes that execute code when an HTTP request arrives. The code usually creates a model and passes it to a view.
The best way to understand MVC is to see a working example.