Add ability to navigate to Blazor @page components more easily
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
I find myself writing static methods or consts like the following for easier navigation between pages without having to remember what the exact url is. It also helps when I need to change a page uri for some reason without breaking all links to it. It'd be great if was supported natively.
MyList.razor
```
@page "/list"
// page content here...
@code {
internal const string Uri = "/list";
}
```
MyPage.razor
```
@page "/mypage/{param1:int}"
// page content here...
@code {
internal static string Uri(int param1) => $"/mypage/{param1}";
}
```
OtherPage.razor:
```
@page "/page2"
```
### Describe the solution you'd like
I propose a NavigationManager static method on to retrieve the page uri for use with an anchor tag href:
It would also be nice to have a similar method for navigation such as the following.
`NavigationManager.NavigateTo(params object?[]? routeParameters = null);`
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.