Developing and testing features or extensions for Microsoft Edge
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Request to please suggest an approach where we can spawn C#,WebView2 application safely without any issue.
Thanks in advance.
Ajay Shinde
Developing and testing features or extensions for Microsoft Edge
Hello @ajay.shinde ,
For this design, the supported direction is to keep the WebView2-hosting C# process in the interactive user's standard, non-elevated security context. The WebView2 security guidance recommends hosting WebView2 in a standard, non-elevated user-integrity process, and User Account Control creates both a standard user access token and an administrator access token when an administrator signs in. So with UAC enabled, you should not need a separate standard user account only to obtain a standard token.
The practical approach is: if the C++ Winlogon\Shell launcher is already running with the standard token, start the C# WebView2 process with normal CreateProcess. If the launcher is running with the elevated administrator token, query the linked standard token with GetTokenInformation using TokenLinkedToken / TOKEN_LINKED_TOKEN, then start the WebView2 process with that real linked token using CreateProcessAsUser or CreateProcessWithTokenW. Avoid creating a hand-restricted token by stripping privileges or SIDs, because WebView2 uses a Chromium multi-process model and the runtime must be able to create its browser, renderer, and helper processes, as described in the WebView2 process model.
Also make sure the WebView2 process is launched in the interactive desktop/session and uses a writable per-user user data folder, for example under %LocalAppData%. If the app still shows a white screen after launching with the real linked standard token, the next useful data is the exact EnsureCoreWebView2Async / CoreWebView2InitializationCompleted exception and HRESULT, plus verbose webview2.log, because that will show whether msedgewebview2.exe is failing during environment/controller creation.
Hope this helps clarify things. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide feedback.
Thank you.