liveBook · Manning

PageModel

A PageModel is an ASP.NET Core Razor Pages class containing page state, data, and request-handling logic.

How 2 Manning books explain it

ASP.NET Core in Action, 3e

A PageModel code-behind file is the C# source file containing the handler methods and state for a Razor Page.

How it is used
Coordinates Razor Page requests through handlers and supplies properties for HTML rendering.
How deep it goes
Works through file association, request handling, binding, and rendering, while deferring detailed routing and binding rules.
Examples
Uses a Privacy page with an empty OnGet handler and a category page backed by an injected to-do service.
What you can do after
Build it from scratch: pair a Razor view with a PageModel that handles requests and exposes data for rendering.

Read how ASP.NET Core in Action, 3e explains PageModel →

Pro ASP.NET Core 7, Tenth Edition

PageModel is the ASP.NET Core base class for classes that provide state and request handlers for Razor Pages.

How it is used
Handles Razor Page requests and supplies properties consumed by Razor markup.
How deep it goes
Explains creation, dependency injection, binding, handlers, redirects, validation, and filters; defers detailed model binding and CSRF mechanics.
Examples
Uses a product editor with GET and POST handlers and a session-backed shopping cart with handler tests.
What you can do after
Build it from scratch as a Razor Page model with request handlers, injected dependencies, and properties for rendering.

Read how Pro ASP.NET Core 7, Tenth Edition explains PageModel →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.