liveBook · Manning

AddPageRoute

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

AddPageRoute is a Razor Pages configuration method that associates an additional route template with a specified page.

AddPageRoute associates an additional route template with one Razor Page. The original route remains available, so the page can be reached through two route templates. section 14.6

Add an alternative page URL

Configure the convention through AddRazorPagesOptions: opts.Conventions.AddPageRoute("/Search/Products/StartSearch", "/search-products"). The page keeps its default route and also responds to /search-products. section 14.6

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

How deep it goes
Explains the retained default route and shows registration, but defers custom route-model convention internals.
Examples
Uses /Search/Products/StartSearch and /search-products to demonstrate an additional route for one page.
What it assumes
Assumes a Razor Pages application configured with AddRazorPages and mapped with MapRazorPages.
What you can do after
Configure an additional Razor Page URL through AddRazorPagesOptions in Program.cs.
How it connects
Connects Razor Pages routing with RazorPagesOptions, the @page directive, and IPageRouteModelConvention.

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.