❔ Simple url parameter not working in blazor wasm???
I have a page with routes:
@page "/Administration/Security/UserAccounts"
@page "/Administration/Security/UserAccounts/{id?}"
first route works but if I use
NavigationManager.NavigateTo($"/Administration/Security/UserAccounts/1");
I get a message saying unable to cast parameter?????
I set up my parameter as a long
@code {
[Parameter]
public long? Id { get; set; }
}
i tried with an int too same thing
I also tried
@page "/Administration/Security/UserAccounts/{id}"
without a question mark
3 Replies
Try as string first.
Then you can try with id:int in the attribute
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-7.0#route-constraints
ASP.NET Core Blazor routing and navigation
Learn how to manage request routing in Blazor apps and how to use the Navigation Manager and NavLink component for navigation.
oh yea {Id:long?} worked thx
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.