Blazor Routing to Page Components
Learn about Blazor routing, creating routable components, navigating routes, handling parameters, and using shared layouts.
The Router component that we saw in the App.razor file enables routing to components. The markup for creating an instance of a component looks like an HTML tag where the tag's name is the component type. Components can be embedded on a web page using an element, for example, <RatingStars="5" />, or they can be routed to, like a Razor Page or MVC controller.
Routable page component
To create a routable page component, add the @page directive to the top of a component’s .razor file, as shown in the following markup:
The preceding code is the equivalent of an MVC controller decorated with the [Route] attribute, as shown in the following code:
The Router component scans the assembly specifically in its AppAssembly parameter for components decorated with the [Route] attribute and register ...