Blazor navigate to same URL but different id

1.7k Views Asked by At

I have problem when navigating from

"/vehicle-definitions/1/can-networks/5" to

"/vehicle-definitions/1/can-networks/6"

Basically, what happens is nothing. I would like and excepted behaviour is to load this new page with id 6, load from database, and show new item on page. But it seems, Blazor thinks this is same page (what basically it is). I tried with <a href , and setting lik using <NavLink but without success

1

There are 1 best solutions below

2
On BEST ANSWER

you have to override the OnParametersSetAsync() methode and reload data from Database.

First change you route like below

/vehicle-definitions/1/can-networks/{id}

Then you set a property with [ParameterAttribute]

[Parameter] 
public string Id{ get; set; }

And now you can override the OnParametersSetAsync methode and reload new data with changed parameter

protected override async Task OnParametersSetAsync()
{
    LoadData(Id);
}