liveBook · Manning

Application model

As explained in ASP.NET Core in Action, 3e

An application model is an architectural component that encapsulates the non-user-interface parts of an application, including domain models, services, and data-access interactions.

An application model is the non-UI part of an application that manages its state and carries out business logic. In a Razor Pages application, it is not necessarily one class: it can encompass a domain model, services, and database interactions. Keeping that work separate from HTML generation makes each part easier to change and test. section 13.4.2 section 13.4.4

In a typical Razor Pages request, the responsibilities are divided:

  • A binding model holds information supplied with the request, such as values from the URL. section 16.1
  • The page handler validates the request, calls the application model through services, and chooses a response based on the result. section 13.4.2
  • The PageModel exposes data to the Razor view, which generates the HTML response. The PageModel is not the application model. section 16.5 section 13.4.4

Viewing a to-do category

Suppose a user requests the to-do items for a category and username. The page handler can call into the application model to obtain the relevant items. That work might involve checking which items the user may view, searching the category, and loading details from a database. Once the details come back, the handler chooses the response; the application model does not create the view. section 13.4.2 section 13.4.4 section 16.1

Figure 16.2 The MVC pattern in ASP.NET Core handling a request to view a subset of items in a to-do list Razor Pages application
CH16_F02_Lock3

Follow the request through the distinct models to see where binding, application logic, and response generation fit. section 16.1

The domain model is one part of this larger concept: it holds complex business logic in classes that do not depend on infrastructure. An application model can also include services and data access. This boundary helps prevent a change to UI code from unexpectedly changing business logic, or vice versa. section 13.4.2 section 13.4.4

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines an architectural boundary and traces its role through a request, without specifying how to implement its services or database access.
Examples
Uses a to-do category request involving permission checks, item searches, database loading, and a page-handler response.
What it assumes
Introduces the application model through an MVC request and explains the domain model rather than assuming either term is familiar.
What you can do after
Evaluate/understand where business logic belongs when separating Razor Page handlers, views, and request data.
How it connects
Distinguishes the application model from binding models and PageModels, and connects it to MVC, domain models, services, and views.

Also explained in

Compare how 2 books explain application model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.