In Blazor web-assembly, is there a reason why should I use NavigationManager over a plain a href link structure?
For example
<a href="/test">Test</a>
<a @onclick="@LinkToTest">Test</a> or
<button @onclick="@LinkToTest">Test</button>
@code
{
void LinkToTest()
{
NavigationManager.NavigateTo("/test");
}
}
Is there a difference how the app would be rendered or routed?
Looking inside the source code for NavigationManager.NavigateTo
, it just invokes an internal javascript function using the JsInterop. Looking at the source on the javascript side, that basically just sets location.href
. So I think it's safe to say that calling NavigateTo
is equivalent to just using a plain href.