liveBook · Manning

Page directive

The @page directive is a Razor directive that identifies a file as a routable Razor Page.

How 2 Manning books explain it

Pro ASP.NET Core 7, Tenth Edition

The @page directive is a Razor directive that assigns one or more URL routes to a Razor component or page.

How it is used
Directs requests to Razor Pages and selects Razor components for declared URLs.
How deep it goes
Works through file-based routes, explicit patterns, multiple routes, and segment values; defers detailed model binding.
Examples
Uses an Index.cshtml product lookup, administration URLs, and a person component with an id segment.
What you can do after
Build it from scratch: assign and verify routes for Razor Pages and components, including URL segment values.

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

ASP.NET Core in Action, 3e

The @page directive is a Razor directive that marks a .cshtml file as a routable Razor Page.

How it is used
Marks .cshtml files as routable Razor Pages and customizes their route templates.
How deep it goes
Explains placement, default routing, appended segments, parameters, and replacement templates, while deferring additional-route preservation.
Examples
Uses Privacy.cshtml, Extra, category and name parameters, and checkout route templates.
What you can do after
Operate/configure Razor Page endpoints by registering pages and defining default, relative, or absolute route templates.

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

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.