microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
Question: How can we add environment parameters to Webview2 under WinUI3
I am trying to disable-web-security for WebView2 Runtime but there is no way to overload the EnsureCoreWebView2Async() function.
Any way we can add "--disable-web-security" to the webview2 runtime under WinUI3? Thank you

@adambarlow fyi
WinUI currently doesn't support the environment parameters. This capability is on the backlog for the future.
There are requests for this capability in https://github.com/MicrosoftEdge/WebView2Feedback/issues/132.
Without this feature, how you can you set the user data cache path? If you're building an unpackaged app with WinUI3 then you don't get the default application data path the user has write access to, you're stuck with it searching the same directory your .exe is in which the user likely doesn't have write access to.
Is there a way to change this user data folder without having access to this API? https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/user-data-folder?tabs=win32
@mlynch You can set a custom user data folder by setting the WEBVIEW2_USER_DATA_FOLDER environment variable in your app. You can read more about this environment variable and others like it here. Some people have experienced problems doing this in WinAppSDK 1.1 after it worked in 1.0 (see https://github.com/microsoft/microsoft-ui-xaml/issues/7190), but I'm still investigating why some people have this issue.
@raaaaay-c You can also set AdditionalBrowserArguments this way. (No reported issues with this one.)
We do plan on exposing the Environment or its options in a more direct way, but we're still working on it.