This article has been updated for the version of WebView2 that requires Microsoft Edge WebView2 Runtime 88.0.705.50 or newer.
Microsoft has replaced its previous IE and Edge browsers with a new version of the Edge browser, based on the Chromium project. The new browser works on Windows 10, Windows 8.x, and Windows 7, as well as macOS, iOS, and Android. If your application display web content, you can use the new Edge browser as the rendering engine. This is made possible through the Microsoft Edge WebView2 control. In this series, I will show how you can do this in a C++ Windows desktop application.
- Part 1: Introduction to Edge and WebView2
- Part 2: Creating a WebView2 component
- Part 3: Navigation and other events
- Part 4: Performing navigation with custom data and headers
From this series you will learn:
- how to add the WebView2 control to your C++ desktop applications
- navigate to pages
- navigate to pages with customer headers or content
- handle browsing events
- use the asynchronous programming model of Edge
- detect Edge installation
- and more…
Why Microsoft Edge
Microsoft has deprecated its Internet Explorer browser and replaced it as default browser on Windows 10 with Edge. Although Internet Explorer is still available in order to maintain compatibility with older websites and intranet sites that require ActiveX and other Microsoft legacy web technologies, it is no longer developed. All efforts are focused on Edge, and the new version of Microsoft Edge is based on the Chromium project.
If you are working on existing Windows native applications that display web content or want to create new ones, you should no longer rely on Microsoft ActiveX web browser control. Using Edge and the WebView2 control is a natural choice because:
- Edge it is the default browser for the platform.
- WebView2 is the control that Microsoft is building for using Edge.
- If you have the Windows automatic updates enabled (and you should) the browser is automatically updated so you do not have to trouble with keeping up with security updates.
How to get the Edge browser
If you are running on Windows 10, Edge should be updated automatically. Nevertheless, you can download it from https://www.microsoft.com/. On Windows, it works on version 10, 8, 8.1, and 7.
The new, Chromium-based Edge browser has a new icon. So you know that you have the browser if its icon looks as follows:
You can check the version of the browser if you go the Edge menu > Help and feedback > About Microsoft Edge. The minimum version that works is 82.0.488.0.
You can also use preview builds of the Microsoft Edge browser by using one of its insider channels:
- Beta channel – major stable updates every 6 weeks
- Dev channel – weekly updates that have been previously tested by the Edge team
- Canary channel – updated daily
For development purposes, you can use any Insider (non-stable) Microsoft Edge (Chromium) browser channel. However, for production, you must use the WebView2 runtime. The WebView2 control is not available in the stable Edge installation and you should not rely on insider channel on production machines.
Why WebView2 Runtime
If you build apps that use the WebView2 component you need to distribute it with your application. The best way to do so is using the Edge WebView2 evergreen runtime. The runtime is a modified version of the Chromium-based Edge intended and tested for apps. Only one installation of the runtime is needed for all apps on the device.
The reason for preferring to target the runtime include the following:
- Does not depend on the Edge browser being installed on the machine, or a particular version of it.
- Updates automatically without additional effort from you.
- It is available to target Win32, WPF, WinForms, and WinUI3 applications (the latter in preview stage).
- In the future, it will be shipped with Windows.
How to get the WebView2 runtime
The runtime is available for download here. You can find both evergreen standalone installers for x86/x64/ARM64 that can be deployed with your app and installed in an offline environment, and an evergreen bootstrapper. This is a small installer that downloads the Evergreen Runtime matching device architecture and installs it locally.
Prerequisites for the demo app
In order to develop, build, and run the demo app in this series, you will need:
- Microsoft Edge WebView2 Evergreen Runtime, version 88.0.705.50 or newer.
- Visual Studio 2015 or later with the Desktop development with C++ workload and the MFC framework installed
- Microsoft.Web.WebView2 NuGet package
- Microsoft.Windows.ImplementationLibrary NuGet package
You can read more about Edge and the WebView2 control from the following resources: