Can Blazor open a URL in a new tab using UriHelper NavigateTo?
Nov 21, 2020
Blazor,
ASP .NET Core Blazor,
Blazor FAQ,
new tab open blazor,
UriHelper NavigateTo blazor,
6949 Views
This code will help you to understand if Blazor opens a URL in a new tab using UriHelper NavigateTo or not.
You have to use the JS interop to achieve this requirement.
public async Task NavigateToUrlAsync(string url, bool openInNewTab)
{
if (openInNewTab)
{
await JSRuntime.InvokeAsync<object>("open", url, "_blank");
}
else
{
this.UriHelper.NavigateTo(url);
}
}
I would suggest you check the below link for better understanding:
https://github.com/aspnet/AspNetCore/issues/8703


