2

When I use WebView2 control in a UWP project with WinUI 3.0 and run the app, the webpage inside WebView2 control is not displayed. Instead, the app displays the following message that takes me to Microsoft Edge for Business download page:

a suitable version of Microsoft edge was not detected. Please install the latest beta channel build from here

Question: Why it's asking for Microsoft Edge for Business? I already have the latest version of MS Edge Canary Channel and the latest release version MS Edge installed on my Windows 10 - Pro. I don't want to install too many versions.

MainPage.xaml:

<Page
  x:Class="UWP_WinUI.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:UWP_WinUI"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
        <WebView2 x:Name="wvTest" Grid.Row="1" Source="https://www.bing.com/"/>
    </Grid>
</Page>

Display of the app

The webpage is supposed to display in the WebVeiw2 below the button control. But instead, the message (shown below) is displayed:

enter image description here

nam
  • 21,967
  • 37
  • 158
  • 332
  • Which version of the Webview 2 you are using in your project? I suggest try to use the supported version of Edge Canary with it may help to fix the error. You can check this document to know the minimum required Edge version for a specific version of Webview2. https://learn.microsoft.com/en-us/microsoft-edge/webview2/releasenotes – Deepak-MSFT Jul 13 '20 at 06:59
  • @Deepak-MSFT This is [WinUI 3.0](https://learn.microsoft.com/en-us/windows/apps/winui/winui3/) project created with their `UWP` template that comes with their built-in latest `WebView2` control. This is different than other projects where you install a suitable version (via NuGeT package) of `WebView2` control etc. I also have the latest version of `MS Edge Canary` installed (that was required by another MS tutorial on WebView2 when I was working on that tutorial). – nam Jul 13 '20 at 15:08

2 Answers2

0

When I use WebView2 control in a UWP project with WinUI 3.0 and run the app, the webpage inside WebView2 control is not displayed. Instead, the app displays the following message that takes me to Microsoft Edge for Business download page

You can use Webview2 in below platforms based on Getting Started:

  • Win32
  • C/C++
  • WPF
  • WinForms

UWP is not one of them. Because UWP is Windows Store App while all the above platforms are Windows Desktop App. So if you want to use Webview2 in your app, you need to switch the platform that you are using. WPF could be a good choice.

Elvis Xia - MSFT
  • 10,801
  • 1
  • 13
  • 24
  • If this is true then I don’t understand the table under controls and Features. It appears to show that webview2 is available. https://microsoft.github.io/microsoft-ui-xaml/about.html#win32 – darbid Aug 15 '20 at 13:55
  • @darbid as [codendone answered in github](https://github.com/microsoft/microsoft-ui-xaml/issues/2888#issuecomment-657652582) What is required is a sufficiently recent install containing the WebView2 runtime with the Beta channel currently recommended. And they haven't tested if WinUI Preview is compatible with that. So for the future, yes it will be supported. But currently it is not recommended to using that for production environment. – Elvis Xia - MSFT Aug 17 '20 at 00:52
0

For "WinUI 3.0 Desktop" it is now a supported platform of WebView2, check out this site for details: https://learn.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winui.

If you plan to ship your WinUI 3.0 app is a UWP app there might be some limitations though, frankly I am no sure on that combo.

Dmitry Lyalin
  • 444
  • 5
  • 8