-1

i have a question about how to redirect page to certain page like google.com

I've tried with below but it's not working...

@inject NavigationManager NavigationManager

void()
{
 NavigationManager.NavigateTo("google.com");
}

but it moved to the link with ultimate uri. like localhost:3030/google.com

how could i move to a page like google.com in Blazor?

GRAGW
  • 9

2 Answers2

1

While void() isn't valid C# I think we can guess what you are trying.

Just "google.com" will be seen as a local (relative) URI, that won't work.

Use:

//NavigationManager.NavigateTo("google.com");
  NavigationManager.NavigateTo("https://google.com");
H H
  • 263,252
  • 30
  • 330
  • 514
0

If you want to visit Google page with click of button, you can do it like this

<button onclick="window.location='http://google.com'">Google</button>
Surinder Singh
  • 1,165
  • 1
  • 3
  • 11