liveBook · Manning

Route convention

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

A Razor Pages convention is a framework rule that derives or configures page behavior and routes from application structure or centralized settings.

A route convention lets Razor Pages derive or adjust route templates from application structure or centralized configuration. By default, a page’s path under Pages closely determines its URL: Pages/Products/ProductDetails.cshtml maps to Products/ProductDetails, while Index maps to the root route. section 14.3 section 14.6

Choose the level of customization that matches the application’s needs:

  • Use the defaults when file-based routes are sufficient; they provide routes for common pages without extra configuration. section 14.3

Standardizing generated URLs

Configure routing once in Program.cs: builder.Services.Configure<RouteOptions>(o => { o.LowercaseUrls = true; o.LowercaseQueryStrings = true; o.AppendTrailingSlash = true; }); This changes generated URLs without editing every Razor Page’s route template.

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

How deep it goes
Moves from default file-based routes through RouteOptions, transformers, and custom conventions, while deferring broader routing mechanics.
Examples
Uses Index, Privacy, and Error pages, ProductDetails paths, lowercase URLs, trailing slashes, kebab-case, and added page routes.
What it assumes
Assumes basic Razor Pages and routing knowledge while establishing default file-based behavior before customization.
What you can do after
Operate/configure Razor Pages URL conventions and apply custom route rules across an application.
How it connects
Links Razor Pages routing with route templates, RouteOptions, parameter transformers, and the middleware pipeline.

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.