microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Question: How can we add environment parameters to Webview2 under WinUI3

Open raaaaay-c opened this issue 4 years ago • 5 comments
trafficstars

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

image

raaaaay-c avatar Jan 30 '21 16:01 raaaaay-c

@adambarlow fyi

StephenLPeters avatar Feb 02 '21 00:02 StephenLPeters

WinUI currently doesn't support the environment parameters. This capability is on the backlog for the future.

codendone avatar Mar 17 '21 20:03 codendone

There are requests for this capability in https://github.com/MicrosoftEdge/WebView2Feedback/issues/132.

krschau avatar Jul 19 '21 22:07 krschau

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 avatar May 08 '22 20:05 mlynch

@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.

krschau avatar Aug 10 '22 19:08 krschau