Bring the best of the Web to your .NET desktop applications with WebView2
This blog post was written together with Palak Goel, Program Manager on Edge Product Development team.
Last year at Build, we introduced WebView2, a browser control that renders web content (HTML / CSS / JavaScript) with the new Chromium-based Microsoft Edge. It was originally limited in scope to C/C++ applications. Today, we are happy to announce the release of the WebView2 preview for .NET applications! WebView2
is available for both .NET Core and .NET Framework. It can be used inside of WPF, Windows Forms and WinUI 3.0 applications all the way down to Windows 7.
Important: When installing the NuGet package, make sure to check Include prerelease checkbox and select a version with the
-prerelease
suffix. Otherwise you will not get .NET support.
Going forward, we will be updating our SDK every six weeks according to the Roadmap, driven by your feedback. You can keep up with the latest updates in the Release Notes.
About the control
With the help of the WebView2
family of controls you can host web content in your desktop .NET applications and enhance them with all the benefits that web has to offer, such as dynamic content, modern user interfaces, and tooling.
A little history
Originally, we started with the WebBrowser
control which is based on Internet Explorer and thus no longer suitable for modern web content. We then created an Edge-based control called WebView
. This control is only available on Windows 10 and can’t be included in your app. We’ve heard your feedback loud and clear that you want a modern and consistent control supported on all Windows versions starting from Windows 7. This is how WebView2
came to life. It is based on the Microsoft Edge Chromium platform, consistent across all Windows versions starting from Windows 7. It receives updates every 6 weeks, enabling you to consume the latest features.
Present
WebView2
supports many features such as navigation, web messaging (communication between the application and the WebView2
control), native object injection (accessing application objects directly from JavaScript) and so on. Check out our documentation for more details. At Microsoft, we are using WebView2
in many of our applications. One example is the Room Finder panel in the desktop version of Outlook. By using WebView2
, we were able to reuse the code from Outlook’s web UI and make it accessible directly to the desktop version.
Future
Currently WebView2
is in Preview and we are working on the GA version. As a part of that effort we will be providing designer support for Windows Forms and WPF so you can enjoy the familiarity of drag-and-drop and WYSIWYG experience. See our Roadmap for more information. Today Windows Forms .NET Framework designer experience is already supported and the rest is coming.
Supported platforms
A developer preview is available for the following programming platforms:
- Win32 C/C++
- .NET Framework 4.6.2 or later
- .NET Core 3.0 or later
- WinUI 3.0
and the following versions of Windows
- Windows 10
- Windows 8.1
- Windows 8
- Windows 7
- Windows Server 2016
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2008 R2
Getting started
Check out our getting started guides:
- Getting started guide for Windows Forms
- Getting started guide for WPF
- Getting started guide for WinUI 3.0
- Getting started guide for Win32
Give us your feedback
Your feedback is our main factor in creating the Roadmap and prioritizing work items. Please share your opinions, suggestions, and details on your scenarios in our feedback repo. We appreciate your help!
27 comments
The good thing with WebView(1) on WPF is that you can simply use it without its bloating up your application size and without the user having to preinstalled something on their computer. It is an out of box working solution.
Brings me back to WebView2 which is using the Chromium Edge, which itself is NOT preinstalled on most computers since it requires a manual installation, especially on Windows 7. So, how does WebView2 works here? Is there a fallback to IE (Windows 7) and (old) Edge on Windows 10 if Chromium Edge is not installed? The last thing we actually need is another prerequirement that simply and silently crash our applications if the user has it not installed.
How much does it increase our application size? Are there any plans to officially replace WebView(1) in WPF with WebView2 by default so this additional size is goes at least into the runtime instead of our application?
It’s a nuget package with no dependencies. So no need to have anything installed. No need to fall back. I dont see a reason why this would ever replace WebView(1). As for bloating it’s 458k.
You do need Edge (chromium version) installed though.
@Max @Merin,
Just wanted to clarify – WebView2 applications, do not require end users to have Chromium Edge installed! The idea is to install the WebView2 Runtime which is “invisible” to the end user.
Hey Max,
Fantastic question! This is feedback we heard LOUD and CLEAR from customers, about what to do if Chromium Edge is not installed on user’s machines. This is why we have developed a WebView2 Runtime, read more about it here: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution
Essentially your application when installed should check if the WebVIew2 Runtime is installed on the user’s machine. If not, it should install the WebView2 Runtime, which will be a shared component all WebView2 applications can share.
As for size we plan to have two options: Evergreen and Fixed Version. The Evergreen version operates like WebView1, where developers target the WebView2 Runtime which we automatically update every 6 weeks, like the browser. Because it is a shared component it does not blow up our application’s disk space. However, we also plan on offering a Fixed version. For developers that don’t want an updating platform, we will provide an option to package the Microsoft Edge bits into your application.
Hope that helps!
Best,
Palak
Makes sense. Good approach. For simple “show a page”, use the system shared viewer which is available as a redist package. For specific control you can embed your own locked version.
Yup! We want to give developers the best of both options!
Hi Palak,
there are a great amount of applications that are portable. I really hope Microsoft would provide Edge Chromium and the WebView2 runtime via Windows Update by default (not by opt-in). Then developers only have to specify a minimum Windows 10 version their application requires and that’s it.
I’m also convinced that this should the case because IE and old Edge are officially “dead”, both have a date of retirement. I know there are hundreds or even thousands of teams at Microsoft and things are a bit more complicated and slower than people like me expect, but perhaps whoever is responsible for WebView2 development should have a little chat with the Windows 10 update team about it.
For Windows 7 etc. having the runtime is a great idea. For Linux / Mac / Android its also a good idea. But for Windows 10 it should be installed by default.
could be usefull if you create WebView2 for other platforms (ios, android, xamarin). It won’t use Edge Chromium rendering engine, but should be highy compatible with other rendering engines, assuming there are no Edge Chromium specific features in WebView2. This will pave way to create cross-platform app UI, with their own set of controls and tools. Currently using WinForms/WPF/Xamarin/XAML/WinUI/upcoming MAUI, is overwhelming. Web browsers (engines) sits everywhere, have huge capabilities and can be used as app UI platform.
@TSX,
This is exactly where we plan to go! We plan to start working on cross-platform scenarios sometime in 2021. If you have any feedback, suggestions, or ideas, please reach out in our feedback channel: https://github.com/MicrosoftEdge/WebViewFeedback/issues
Best,
Palak
Does this one work with elevated UAC? The first version didn’t, right? I feel like that’s why I couldn’t implement it. I need it for SSO but there are cases when I need to elevate the process.
Is there any work being done to update Visual Studio’s internal WPF web control to WebView2?
The current WebBrowser control is still IE-based, and the WebView2 control requires the canary version of Edge to be installed and doesn’t work in custom WPF tool windows when creating a VS extension.
Hello. 😊 Thanks for letting us know about WebView2. If you don’t mind, I have a couple of questions. I’m quoting the relevant sections of the post.
Host web content or simply access web content hosted elsewhere? Please answer carefully; I’m already looking for a solution to host local web content, thus creating rich client-side apps with web technology.
Let’s see if I am understanding correctly: Are you saying that at Microsoft, you are using Beta-grade components in production-grade apps? (That’s … worrisome.)
Hey Fleet Command,
You can host web content by creating your own local HTML/CSS/JS content or you can access web content hosted elsewhere.
Fortunately not! The post is referencing an internal future version of Outlook that will ship once the WebView2 control GAs.
I’d really want to know when this will actually make it back to UWP – WinUI 2, that is.
It’s simply useless to have it WinUI 3 ready, when WinUI 3 production ready is pretty much 1 year away.
Hey Ion Sorin Torjo,
Unfortunately, WebView2 will make its way into UWP with Win UI 3.0. We do have a preview released, which I encourage you to check out!
https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winui
How is today’s “happy announcement” different from what we’ve had already 3 months? I’ve used WebView2 preview on my classic WinForms C# .NET application running on Windows Server 2019 since it was announced in Build conference in May 2020.
Hey Jussi Palo,
That’s great, we appreciate you developing with WebView2! Since Build, we’ve updated the SDK twice and want to increase awareness of the WebView2 control to the .NET developer community.
It would be very nice with Linux and macOS support so WebView2 could be used to develop cross-platform .NET Core desktop applications.
Hey,
We’d love to see it too and that’s where we are heading! Stay tuned!
@Palak Goel …
There is no cross-platform .Net Core desktop technology from Microsoft. Where do you plan to put your WebView2? Are you talking about WINUI for xbox? Are you talking about xamarin forms? What do you mean by this statement? Where exactly are you heading?
The announcement was related to .NET Core and .NET Framework. It said that the WebView2 can be used inside of WPF, Windows Forms and WinUI 3.0 application. None of those are considered cross platform technologies. WinUI is the closest, but I don’t think anyone uses the term “cross platform”. You are really confusing us …
Is there any way to integrate this in a C# Unity 3d (game) engine application (for windows builds)?
Getting started (“Начало работы”) links are broken for ru-ru locale (https://docs.microsoft.com/ru-ru/microsoft-edge/webview2/#getting-started):
image