Routing
In Blazor WebAssembly, routing is handled on the client, not on the server. As you navigate in the browser, Blazor intercepts that navigation and renders the component with the matching route.
The URLs are resolved relative to the base path that is specified in the wwwroot/index.html
file. The base path is specified in the head
element using the following syntax:
<base href="/" />
Unlike other frameworks that you may have used, the route is not inferred from the location of its file. For example, in the Demo
project, the Counter
component is in the /Pages/Counter
folder, yet it uses the following route:
/counter
This is the @page
directive used by the Counter
component:
@page "/counter"
Route parameters
Route parameters can be used to populate the parameters of a component. The parameters of both the component and the route must have the same name, but they are not case-sensitive.
You can provide more than one...