-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebView2 initialization in headless mode not work when is invoked by windows service #3458
Comments
Could this be related to #1907? That's an unsupported scenario. |
No, in my scenario the windows service run under a user that is administrator |
Then that could be due to difficulty to create non elevated WebView2 processes. WebView2 processes cannot run elevated. For normal session, we create non elevated WebView2 processes through explorer. I would imagine that it doesn't work when running in windows service. So, this is a scenario that we do not support currently. |
To avoid misunderstandings I explain my scenario: This is the windows service that start the web application in ASP.NET Core 6.0. It is executed by the user "ServiceExecutor", that is local administrator: Clicking on the button Export, it calls the action "ExecProcess" that execute the console application "ConsoleApp1.exe" that initialize WebView2 in headless mode, navigate and export in pdf. The process started by the user "ServiceExecutor", but nothing it is exported. This scenario could be supported? Thanks for support! |
This is a setup WebView2 has not been tested with, and therefore not officially supported. In the setup, ConsoleApp1.exe is running elevated and as different user, probably in an invisible session. We have several hurdles to overcome: launch de-elevated WebView2 process, which depends on explorer, allow the launched WebView2 process running as different user (the same interactive user as explorer) to access connection end point created by the elevated process, and Chromium's sandbox code works in this invisible session. That being said, WebView2 code might have already overcome the first 2 hurdles and it is the Chromium's sandbox code that is preventing it from working. You could try to create WebView with --no-sandbox additional browser arguments ( If it doesn't work, it is the first 2 hurdles that is breaking the scenario. Try to use latest version of Edge WebView2 runtime and see whether it works. We made some changes related to elevated app in Edge 112, which might or might not help. If still does not work, could you try to config it to run as a non admin user? |
I try your suggestions and it works when the Windows Service run with a user that is NOT administrator. |
If it works with non admin but not with admin even using --no-sandbox, it means that dependency on explorer is the one that prevents it from working. Therefore, it is a WebView2 limitation with no workaround. Running the service with non admin account is the only workaround. |
Hi,
i'm trying to use WebView2 in headless mode to export in pdf a page but when is invoked by a Windows Service doesn't work.
This is the scenario.
I have a web application named "WebAppService" in ASP.NET Core 6.0. running an html page.
In the HTML page there is a button and on click is called a web API that execute the console application used for the initialization of WebView2 and the export in pdf.
The executable invoked "ConsoleApp1" contains the methods to initialize WebView2 in headless mode, navigate and export in pdf.
When the web application "WebAppService" is running in debug mode in Visual Studio (or invoked by a Console Application), the export works.
When the web application is invoked by a Windows Service, the export doesn't work: the "ConsoleApplication1" is executed, but it stucks at method "CreateCoreWebView2ControllerAsync" (no exceptions are returned).
I'm using WebView2Runtime.110.0.1587.63.x64
Thanks for your help!
Fabio
The text was updated successfully, but these errors were encountered: