liveBook · Manning

Model–view–controller

As explained in Pro ASP.NET Core 7, Tenth Edition

MVC is an architectural pattern that separates an application into models, views, and controllers.

Model–view–controller (MVC) is an architectural pattern that separates application concerns into models, views, and controllers. It emerged as an alternative to Web Forms, embracing the behavior of HTTP and HTML instead of hiding it behind a desktop-style programming model. section 1.1.1

In ASP.NET Core, the three parts divide responsibilities:

  • Models provide the data model used by the application. section 19.4
  • Controllers organize request handling and can define a web service in a single class. section 19.4
  • Views produce HTML responses, including responses rendered with Razor. section 19.4

Controller-based web service

A controller can keep related response work together instead of repeating it across URL endpoints: obtain the Entity Framework Core service, query the database, set the response Content-Type, and serialize objects as JSON. This keeps Program.cs from becoming unwieldy. section 19.4

MVC remains useful, but it is no longer the only organizing style in ASP.NET Core. Single-page applications and other approaches can reduce the need to follow the full pattern, while controllers still support web services and MVC controllers with views support form applications. section 1.1.1 section 19.4 section 31.2

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Defines separation of concerns and controller usage, but stops short of detailing Razor view implementation.
Examples
Uses controller-defined web services and MVC controllers with views for core data operations.
What you can do after
Apply it via ASP.NET Core controllers, models, and views to structure web services and form applications.
How it connects
Connects separation of concerns with HTTP, HTML, Web Forms, ASP.NET Core, controllers, models, views, SPAs, and Razor Pages.

Also explained in

Compare how 4 books explain Model–view–controller →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.