-
Book Overview & Buying
-
Table Of Contents
Blazor WebAssembly by Example - Third Edition
By :
In Blazor WebAssembly, routing is managed 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
Blazor routes are explicitly defined with the @page directive. This is the @page directive used by the Counter component:
@page "/counter"
Routable components should use kebab-case for URLs. For example, if you create a component called TaskList.razor, it will use the following route:
@page "/task-list"
Kebab-case writes every word...