webview2/c# problem with exiting webview2 window.

Thad T 26 Reputation points
2021-03-31T14:39:29.5+00:00

Recently, I put together C# and webview2 mix , to access some web pages from a c# program, and the end results were quite nice; a working c#/webview2 webpage window. It was just a simple, barebones approach. And it did not return any errors. But the problems came when I exited out of the webview2 window under the C# procedure and returned control back to the calling form/procedure_call. When the calling control was returned, the current form was overlayed by the webview2 webpage window - it was still waiting to be used - it didn't delete! There was nothing that could be done to terminate the window inside, so the process had to be manually terminated. What else needs to be done to exit out of the webview2 window seemlessly? It's just a simple approach, and I am not well versed in webview2 tools. What else do I need to incorporate into the c#/webview2 program to make it work the way I want it to be? Any help sure would be Great! Thanks in advance.
I'm using MSVC 2017.

Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 90,681 Reputation points
    2021-03-31T14:45:40.837+00:00

    I followed the MSDN tutorial (Getting started with WebView2 in Windows Forms) and it works fine for me
    Windows 10, VS 2019, WebView2 Runtime installed)

    0 comments No comments

  2. Elias 21 Reputation points
    2021-06-06T09:20:46.153+00:00

    I have the same problem.
    To reproduce the problem, all you need to do is call a popup frame window containing a WebView2. When you close the popup frame window, you will see that the WebView2 is hanging and waiting to be closed manually. There is no way to close it until you exit your application. The workaround is to call the Hide method on FormClosed.

    0 comments No comments

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.