How to use new WebBrowserControl in .Net 5

john zyd 421 Reputation points
2021-02-11T21:32:47.51+00:00

Hello:
I found there seem to be a new version of WebBrowserControl for .NET 5 Window Form, check this URL: I believe it is a new one for Chrome based browser, not the old one for IE.
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.webbrowser?view=net-5.0
But I can’t find any code sample for this.
I want to do the following simple thing:
I want to launch Edge (Chrome) browser to visit https://www.bing.com/
Then in the input box, input “webbrowsercontrol .net 5”
Then click the search icon.

Can someone share some code samples to carry out the above simple steps.
My IDE: Visual Studio 2019 Version 16.8.5 on Windows 10 (Version 20H2)
By the way, what is the difference between this WebBrowserControl and WebView2? Can WebBrowserControl run JavaScript directly or not?
Thanks,

Developer technologies Visual Studio Debugging
Developer technologies Visual Studio Testing
0 comments No comments
{count} votes

Accepted answer
  1. Sam of Simple Samples 5,546 Reputation points
    2021-02-11T23:09:21.113+00:00

    That page does not state explicitly that the WebBrowserControl uses IE but if you search that page for Internet Explorer you will see that it does. So that is what the WebView2 control is for; it supports Edge instead of IE.

    Use of the WebView2 control involves more than sample code; you need to also install the WebView2 SDK using NuGet. See Getting started with WebView2 for WinForms apps - Microsoft Edge Development | Microsoft Learn for full instructions and sample code.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.