Training
Module
Use pages, routing, and layouts to improve Blazor navigation - Training
Learn how to optimize your app's navigation, use parameters from the URL, and create reusable layouts in a Blazor web app.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
A bug in the Blazor routing implementation affected how the precedence of routes was determined. This bug affects catch-all routes or routes with optional parameters within your Blazor app.
5.0.1
With the erroneous behavior, routes with lower precedence are considered and matched over routes with higher precedence. For example, the {*slug}
route is matched before /customer/{id}
.
The current behavior more closely matches the routing behavior defined in ASP.NET Core apps. The framework determines the route precedence for each segment first. The route's length is used only as a second criteria to break ties.
The original behavior is considered a bug in the implementation. As a goal, the routing system in Blazor apps should behave the same way as the routing system in the rest of ASP.NET Core.
If upgrading from previous versions of Blazor to 5.x, use the PreferExactMatches
attribute on the Router
component. This attribute can be used to opt in to the correct behavior. For example:
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="true">
When PreferExactMatches
is set to true
, route matching prefers exact matches over wildcards.
None
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Use pages, routing, and layouts to improve Blazor navigation - Training
Learn how to optimize your app's navigation, use parameters from the URL, and create reusable layouts in a Blazor web app.