Windows 11 update - KB5030219 - Unable to enter issue on the WebView2 browser text box keyboard.

QZ ouyang 0 Reputation points
2023-09-21T06:02:07.68+00:00

On my computer system Windows11, after updating security patch KB5030219, I created a UWP application using Visual Studio Enterprise 2022. After using WebView2 component in the application to access the URL that requires x509 certificate authentication, The certificate window popped up and when I clicked Cancel, the text field in the HTML content layout couldn't accept any text input from the keyboard.

Here are the steps to reproduce:

  1. Visit the website "https://support.microsoft.com/en-us/topic/september-12-2023-kb5030219-os-build-22621-2283-8b9ba74f-fdde-4c75-b049 -77cf214f4a66" Download and install the security update KB5030219 for Windows 11.Screenshot 2023-09-21 130719
  2. Open Visual Studio Enterprise 2022 and select File=> New=> Project... ; Then select C# & Windows & UWP, click Blank App(Universal Windows), enter in the project name "BrowserApp" and click Create button to generate a UWP application.
  3. Right-click the project you just created and select "Manage NuGet Packages..." , search and add NuGet packages "Microsoft.UI.Xaml" & "Microsoft.Web.WebView2".Screenshot 2023-09-21 011149
  4. Double-click the "Package. appxmanifest" file in the project solution, and checked the "Shared User Certificates" item in the list option of the Capabilities table page.Screenshot 2023-09-21 131632
  5. Finally, type the following code in the "MainPage.xaml "&" MainPage.xaml.cs "files, then debug and run to reproduce the problem described.

MainPage.xaml Code:

<Page
    x:Class="BrowserApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BrowserApp"
    xmlns:controls="using:Microsoft.UI.Xaml.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Loaded="BrowserWindow_Loaded">

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <CommandBar x:Name="appCommandBar" Grid.Column="0" OverflowButtonVisibility="Collapsed">
                <AppBarButton IsCompact="True" Icon="Back" Click="AppBarButton_BackClick">
                </AppBarButton>
                <AppBarButton IsCompact="True" Icon="Cancel" Click="AppBarButton_CancelClick">
                </AppBarButton>
            </CommandBar>
            <TextBox Grid.Column="1" x:Name="txtUrl" Text="https://mobilestg-ae3be903b.hana.ondemand.com/SAMLAuthLauncher" 
                     HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5,0,0,0" Width="520"
                     KeyDown="txtUrl_KeyDown" />
            <Button Grid.Column="2" x:Name="btnNavigate" Content="Go" HorizontalAlignment="Left" VerticalAlignment="Center"
                     Margin="5,0,0,0" Click="btnNavigate_Click"/>
        </Grid>
        <controls:WebView2 x:Name="wvBrowser" Grid.Row="1" Source="about:blank"/>

    </Grid>
</Page>

MainPage.xaml.cs Code:

using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace BrowserApp
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }
        private void BrowserWindow_Loaded(object sender, RoutedEventArgs e)
        {
            wvBrowser.Focus(FocusState.Keyboard);            
        }

        private void AppBarButton_CancelClick(object sender, RoutedEventArgs e)
        {
            wvBrowser.CoreWebView2.Stop();
        }

        private void AppBarButton_BackClick(object sender, RoutedEventArgs e)
        {
            wvBrowser.CoreWebView2.Stop();
            if (wvBrowser.CanGoBack)
                wvBrowser.GoBack();
        }

        private void txtUrl_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if(e.Key == Windows.System.VirtualKey.Enter)
            {
                btnNavigate_Click(null, null);
            }
        }

        private void btnNavigate_Click(object sender, RoutedEventArgs e)
        {
            string url = txtUrl.Text.Trim();
            if (!string.IsNullOrEmpty(url))
                wvBrowser.Source = new Uri(url);
        }
    }
}

OS Environment: Windows 11 Enterprise , Version 22H2

C# .Net UWP WebView2 x.509 certificate

This problem only occurs when security patch KB5030219 is installed, It is not clear why this affects the functionality of the WebView2 dev kit, but it seems to disable all WebView2 keyboard events after the x.509 certificate selection is displayed. But I didn't find any Settings that enable or set WebView2 to enable keyboard event listeners.

During the test, I found that you can uncheck the option of "Shared User Certificates" and it will work normally, but the functional business needs to require the option of x.509.

I hope that the technical support of Microsoft team and the elite technical staff in the community can help solve the questions and answers, Thank you!

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,801 questions
Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,853 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.