C# Using Edge Web.WebView2

Use WebView2 in WinForms applications. Windows App SDK WebView2 Public WebView2 Available in Windows App SDK with Edge and WinUI Cooperate to backport the WebView2 control to WinUI2. Windows UI Library (WinUI) 2 Integrate with Windows SDK and use XAML Islands() Provides official native Windows UI controls and other user interface elements for UWP applications.

Visual Studio C# ASP.NET application, replace the application WebBrowser with Microsoft Edge WebView2 WinForms applications embed Microsoft Edge (Chromium) platform web content. Permanent launch loader, by default WebView2 will be “permanent” and receive automatic updates to stay up to date and the most secure platform. This “permanent” will depend on future network changes. The Internet Explorer browser will be completely phased out on 2022/06/15 and will no longer support IE 11 browser legacy applications, and it is recommended to move to Microsoft Edge< /strong>. WebBrowser that originally worked locally can also use new network technologies.

WebView2 Microsoft Edge

The new version of Microsoft Edge browser uses the same Chromium core as Google Chrome and applies web technologies HTML, JavaScript, and CSS natively, so It can provide better web compatibility and also provide the long-lost macOS version. Chromium Core is a free open source software project released by Google to develop the Google Chrome browser since 2006. In order to create a safe, stable and fast universal browser, The BSD license terms and other licenses are released and open source. Chromium, Google Chrome share most of the browser code and JavaScript with ECMAScript, ES6 strong> Grammar support function.

Edge installs the updated new version of Chromium core Edge‘s default browser in the official Microsoft. You can adjust the settings to decide how much you want to protect your privacy and set up predetermined search engines and expanded functions. When considering web design, you should gradually get rid of the constraints of previous compatibility.

First download WebView2 execution phase

Microsoft Edge WebView2 Runtime, WebView2 controls can be used in native applications powered by Microsoft Edge (Chromium) Embed current web technologies HTML, CSS, ECMAScript, JavaScript without this Visual Studio 2017< /strong> There is no way to display the content of the specified Source URL.

WebView2 – Microsoft Edge Developer

MicrosoftEdgeWebview2Setup.exe

Visual Studio

Microsoft Edge WebView2 is based on the new version of Microsoft’s Chromium and is part of the core Edge browser that continues to receive many optimizations. The browser first came pre-installed in Windows 10 version 20H2. Update to C# Windows Forms that originally worked natively.
Tools Tools (T) in the Visual Studio menu, NuGet Package Administrator, Manage Plans NuGetSuite.

Microsoft.Web.WebView2

Set up development tools and create initialWebView2 applications for the WinForms platform. Component development applications require Microsoft Visual Studio version Visual Studio 2017 or higher such as Visual Studio 2022 Professional.

Change the source attribute of the WebView2 control

using System.Windows.Forms;

.NET API browser displays the content of the currently specified source URL after the initialization of CoreWebView2 is completed. Obtaining this attribute is equivalent to obtaining the Source attribute and setting the attribute Navigate< /strong>(String) method.

this.WebView2.Source = new System.Uri("https://www.microsoft.com", System.UriKind.Absolute);

Uri obtains information about the currently requested URL, provides an object representation of the Uniform Resource Identifier URI, and provides easy access to various parts of the URI.

Step reference for getting started with WebView2

in a WinForms application

WebView2 is a new generation browser control based on Microsoft Edge that can be embedded in Microsoft Visual Studio applications to display web content in the application and Provides the same functionality and experience as modern browsers. Allow applications to support new generation browser solutions, such as ECMA-262 and other new syntaxes.
Get started with WebView2 in WinForms apps

webView21.CoreWebView2.Navigate("https://www.example.com");

Get started with WebView2 in WinForms apps – Microsoft Edge Development | Microsoft Learn

Chromium shares much of its code with Google Chrome

A browser compiled based on the Chromium kernel and focused on protecting browser privacy project Microsoft Edge package. To use Edge Web.WebView2 in C#, you need to make sure that Microsoft Edge version 80 or higher is installed on your computer. , and install Microsoft.Edge.WebView2 NuGet using the NuGet Manager in the Visual Studio Toolbox.

Microsoft Edge Chromium

After the Class Classic Edge is officially retired, Microsoft will put most of its focus on the new Edge Chromium to provide support for current web technologies.

It is unknown what will happen to the programs applied to this machine after the Internet Explorer browser is deprecated. WebBrowser is changed to WebView2. For example, document.execCommand(“cut”) is for security reasons. There are minor layout changes, but they should still be followed as the times progress.

Registry modification webbrowser specifies the kernel as IE11

Computer\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

11001(0x2AF9) – Internet Explorer11. No matter! Regardless of the DOCTYPE directive, web pages are displayed in IE11 edge mode.
11000(0x2AF8) – Internet Explorer11. Contains standards based! Web pages with DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.

The correction result still does not support the current web technologies HTML, CSS, and JavaScript. It is recommended to use WebView2 to replace it, and the application can also be upgraded.

Web source: C# WinForms using Edge Web.WebView2

syntaxbug.com © 2021 All Rights Reserved.