Is there a way to navigate to a singular url with a button in WebView2?

core hacked 116 Reputation points
2021-03-26T19:27:12.2+00:00

Hello,
I was looking for a way to navigate to a singular URL using a string eg.

private void HomePageBtn_Click(object sender, EventArgs e)
        {
            string HomePage = "https://www.microsoft.com/";
            webView1.NavigateToString(HomePage);

        }

All the browser control displays is the URL as text in a fully white window.

I have not found any articles or mentions of navigation via a string, if someone knows how to help/what I did wrong, please help.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,825 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,226 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.1K Reputation points
    2021-03-26T19:30:10.867+00:00

    Try this:

    webView1.CoreWebView2.Navigate( HomePage );
    

0 additional answers

Sort by: Most helpful