Reputation: 171
I came up with a strange task.
I have 3 Blazor components with dynamic pages, and do not understand how I can release it.
Q: How can I can reduce the number of lines @page "/"... @page "/...{section}"
Or maybe who know how I can exclude some urls like @PageExlude "..."
[HomePage.razor]
@page "/"
@page "/{section1}"
@page "/{section1}/{section2}"
...
@page "/{section1}/{section2}/.../{sectionX}"
.... CODE ....
[AdminPage.razor]
@page "/admin/"
@page "/admin/{section1}"
@page "/admin/{section1}/{section2}"
@page "/admin/{section1}/{section2}/{section3}"
@page "/admin/{section1}/{section2}/{section3}/{section4}"
.... CODE ....
[PreviewPageContent.razor]
@page "/admin/previewPage/{PageId:int}"
@page "/admin/previewPage/{PageId:int}/{Revision:int}"
.... CODE ....
for people who do not understand the task:
when I call -> Result
localhost/ -> HomePage.razor
localhost/admin/ -> HomePage.razor
localhost/previewPage/1 -> HomePage.razor
localhost/Identity/Account/Manage/Index -> HomePage.razor
Upvotes: 3
Views: 1352
Reputation: 83
Catch-all route parameters are another way to handle this.
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-6.0
Upvotes: 2