PageModel
A PageModel is an ASP.NET Core Razor Pages class containing page state, data, and request-handling logic.
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.
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
- handlerhas part · A handler is a callable or software component that processes an event, request, message, or other input and performs associated processing.
- Razor Pagespart of · Razor Pages is an ASP.NET Core page-focused programming model in which independently addressable pages combine Razor markup with request-handling logic.
- model directiveconfigured by · The @model directive is a Razor directive that declares the model type associated with a page or view.
- Razor syntaxused by · Razor syntax is a templating syntax that combines markup with embedded .NET code and directives to generate web content.
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.

