-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
This page says "Optional parameters aren't supported."
This is no longer true. See #19733
I have tested and it works great.
For example: @page "/viewpost/{code?}"
routes to the viewpost
page for both of these routes:
/viewpost
'viewpost/test'
I have tested this with both SS and CS Blazor and it worked correctly.
Would suggest the following:
Remove this paragraph:
Optional parameters aren't supported. Two @page directives are applied in the previous example. The first permits navigation to the component without a parameter. The second @page directive takes the {text} route parameter and assigns the value to the Text property.
Replace with:
Optional parameters are supported by Blazor on both Server and WebAssemebly appss. Two @page directives are applied in the previous example. To reduce to one, use this syntax: @page "/RouteParameter/{text?}
. This will match both /RouteParameter
and /RouteParameter/optional
. The first route sets the Text parameter to null
(or the default value if provided as in this example), while the second route sets it to optional
.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 35474d24-8039-f04a-de14-1530b8e8506c
- Version Independent ID: b6cb2574-6326-a40d-0b6c-d1661328e828
- Content: ASP.NET Core Blazor routing
- Content Source: aspnetcore/blazor/fundamentals/routing.md
- Product: aspnet-core
- Technology: aspnetcore-blazor
- GitHub Login: @guardrex
- Microsoft Alias: riande
Metadata
Metadata
Assignees
Labels
Type
Projects
Status