C
C#3y ago
malkav

Blazor routing with multiple parameters [Answered]

is there someone who can explain why my blazor page isn't taking 2 parameters in the route? I've got this as route (example): /user/{previous}/print/{userid} which resuls in one of two things (at the moment): /user/profile/print/[userid] or /user/admin-something/print/[userid] but only the first of the two seems to actually present the page I desire, the second one however, gives me the "Sorry, there's nothing at this address" screen.... What am I missing? My page's Code section looks like this:
// @code {
[Parameter]public string previous {get;set;}
[Parameter] public string userid {get;set;}

// Other parameters here
private bool _isReady;
// ...

// Method section
private void SomeMethod()
{
// ...
}

private void NavigateBack()
{
NavManager.NavigateTo($"/{Previous.Replace("-", "/")}");
}
// @code {
[Parameter]public string previous {get;set;}
[Parameter] public string userid {get;set;}

// Other parameters here
private bool _isReady;
// ...

// Method section
private void SomeMethod()
{
// ...
}

private void NavigateBack()
{
NavManager.NavigateTo($"/{Previous.Replace("-", "/")}");
}
Top of the page:
@layout PrintingLayout
@page "/user/{previous}/print/{userid}"


@inject IJSRuntime Js // for calling print PDF functions
@inject NavigationManager NavManager
@layout PrintingLayout
@page "/user/{previous}/print/{userid}"


@inject IJSRuntime Js // for calling print PDF functions
@inject NavigationManager NavManager
2 Replies
malkav
malkavOP3y ago
Edit: I've even tried to do the "catch-all" routing so my route looks like this: @page "/user/print/{userid}/{*previous} with ofc [Parameter]public string previous {get;set;} but still, the route /user/print/[userid]/Profile results in the page just fine, but /user/print/[userid]/Admin/Something returns "Sorry there's nothing at this address." nevermind I'm an idiot... I've set the <a href=""> to contain the url to the live page instead of just the route... so I had https://....../users/... instead of /users/.... so I'm stupid and this is resolved
Accord
Accord3y ago
✅ This post has been marked as answered!

Did you find this page helpful?