liveBook · Manning

URL scheme

As explained in Pro ASP.NET Core 7, Tenth Edition

A URL scheme is the application-defined structure used to format and interpret URLs.

A URL scheme defines how an application formats and interprets its URLs. In SportsStore, routing replaces query-string pagination such as /?productPage=2 with composable paths such as /Page2. section 7.4.2

ASP.NET Core routing handles incoming requests and generates outgoing URLs, keeping browser links and application routes consistent. Route templates map paths to the Home controller’s Index action. section 8.1.2

Define routes in Program.cs

app.MapControllerRoute("catpage", "{category}/Page{productPage:int}", new { Controller = "Home", action = "Index" }); app.MapControllerRoute("page", "Page{productPage:int}", new { Controller = "Home", action = "Index", productPage = 1 }); app.MapControllerRoute("category", "{category}", new { Controller = "Home", action = "Index", productPage = 1 }); The int constraint distinguishes numeric page values, while route defaults make the root and category URLs represent page 1.

Generated links can receive route values from Razor tag helpers. A page-url-category attribute is collected into a dictionary and passed to IUrlHelper.Action, allowing pagination links to follow the same category-aware scheme. section 8.1.2

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Demonstrates route templates, constraints, defaults, and link generation, but defers detailed routing mechanics.
Examples
Uses /Page2, /Soccer, and /Soccer/Page2 alongside Program.cs routes and pagination tag-helper attributes.
What it assumes
Assumes ASP.NET Core controllers, Program.cs configuration, and Razor tag-helper usage.
What you can do after
Apply it via ASP.NET Core routing to replace query-string URLs and generate consistent pagination links.
How it connects
Connects routing with controller actions, pagination, categories, Razor tag helpers, and IUrlHelper.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.