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.
