Skip to content

Update documentation for Optional Parameters in Routing #20591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gregoryagu opened this issue Nov 15, 2020 · 0 comments · Fixed by #20593
Closed

Update documentation for Optional Parameters in Routing #20591

gregoryagu opened this issue Nov 15, 2020 · 0 comments · Fixed by #20593
Assignees
Labels
Blazor doc-enhancement Pri1 Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@gregoryagu
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blazor doc-enhancement Pri1 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants