In the ancient days of the 1990s, when the internet was a new and trendy invention, programmers wondered if it might be a good vehicle for applications. So we tried to take the desktop technology of the time and wedge that into our web browsers. We used tools like ActiveX plugins and Java applets. We used embarrassingly bad, proprietary plugins like Office Web Components and FrontPage Extensions. Most sensible programmers stayed far away.
Despite the popularity of hybrid applications, modern solutions for rolling your own are a bit of a patchwork. If you don’t want to use a full framework like Electron, you need to rely on a system control like
WebBrowser (the original, IE-powered window for hosting web content) or the newer
Microsoft has been promising a fix for a while. They demonstrated a successor to
WebView for C++ applications at last year’s Build conference. Now this successor,
WebView2, is finally arriving and finally supports all types of Windows applications.
Here’s the big picture.
WebView2 runs on any version of Windows, reaching back to Windows 7. Microsoft also claims that it works on versions of Windows Server all the way back to the preposterously old Windows Server 2008 R2 (a fact that’s both incredible and mostly useless).
WebView2 is guaranteed to use the Edge browser’s implementation of the good old industry standard Chromium engine. On pre-Windows 10 computers, there’s a small distributable that you may need to include (essentially, a componentized version of Edge). Once you do you’re guaranteed the latest version of the Edge rendering engine, in perpetuity. There’s also a “fixed” mode that lets you lock your application down to the version of Edge you built it with. But if you go this route, it’s up to you to manage the distribution of Edge updates, and accept the security risk of old versions.
The wide compatibility and lightweight nature of
WebView2 is impressive. It’s enough to make me forgive Edge for its aggressive attempts to sneak into my task bar and take over the default browser setting. (For the record, I think that Edge is a dramatically better browser than IE, but still plagued by some quirks. It’s best features are the ones copied from Chrome, and — although I won’t judge anyone who picks it for their daily driver — Edge still hasn’t become my favorite browser.)
WebView2 also has expansive application support. Its first early preview version was for C++ only. Now it runs on the .NET Framework both new and old (from .NET Framework 4.6 and .NET Core 3, to the future, .NET 5). And your choice of applications isn’t limited, because
WebView2 works seamlessly in every important type of Windows application, including WPF, the new version of WinUI, Windows Forms, and even old-school Win32, as you would expect.
WebView2 is already turning up all over Office, including in the desktop version of Outlook, where it hosts the Room Finder panel.
WebView2 still isn’t finished, it’s finally graduated to a preview release, and Microsoft has plenty of documentation and sample content. General availability for all application types is slated for the end of the year.
The future of
WebView2 could be even brighter. It’s easy to imagine
WebView2 facilitating a lightweight alternate to Electron with none of the Node.js overhead. And it’s particularly relevant now that Microsoft is experimenting with approaches that can lower the desktop hosting footprint for Blazor. In fact, given the popularity of Electron and all types of hybrid applications, it’s surprising how long it’s taken Microsoft to get this working. And it makes their decision to abandon IE and adopt Chromium even easier to understand.
For Microsoft news, programming deep dives, and occasional humor, subscribe to the monthly Young Coder newsletter.