MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
453 stars 55 forks source link

How can I use CapturePreview when running on an IIS Web Server? #2114

Closed TonyK1 closed 1 year ago

TonyK1 commented 2 years ago

Our application is a dashboarding application that runs as both a Desktop application and an ASP.NET web application. Our core dlls are shared between both environments and are written in C++. The dashboards are rendered using the same JavaScript in both environments. In the Desktop product we were using the old WebBrowser IE control to render the dashboards. We have now upgraded the code to use WebView2. Part of our functionality is to publish presentations in PowerPoint containing a number of user-selected dashboard panels. We generated these by using a second internal WebBrowser control and IViewObject to draw the browser display into a bitmap. Now, with WebView2, we are using CapturePreview. This works fine within the Windows Desktop application, but fails in the Web application. The ICoreWebView2CapturePreviewCompletedHandler method never gets called.

I have a CView as the parent of the WebView2 control and have given it the Desktop Window as its parent. I have also tried ensuring the CView is visible with ShowWindow.

Is it possible to get CapturePreview working in the ASP.NET environment like this? If not, is it possible to update WebView2 to support this requirement?

champnic commented 2 years ago

Hey @TonyK1 - Could you describe a bit more about how the ASP.NET web application is using and interacting with the WebView2?

TonyK1 commented 2 years ago

A lot of our code is written in C++. This is accessed via a mixed managed interface from the C# code that implements our Web APIs. We send a request to the C++ code to render specified dashboard panels as bitmaps, insert them into a PowerPoint presentation and then download the file to the browser. In the browser, the user only sees a single panel at a time. WebView2 was being used to render each panel on the server as a bitmap for saving in the PowerPoint file. This was working fine within our MFC desktop application. My workaround is to restore some of the original IE functionality as a secondary embedded web browser in our new architecture and use that for publishing panel bitmaps from the Web Server. However, this is not satisfactory because it limits our TypeScript/HTML development as we cqan't support the very latest standards (one reason for moving to WebView2/Edge).

TonyK1 commented 2 years ago

Has any progress been made with WebView2 to allow CapturePreview to work in an ASP.NET server environment?