NativeWebView exposes two option-request events during initialization so applications can adjust backend defaults before the platform engine is created.
Event: CoreWebView2EnvironmentRequested
Option model:
BrowserExecutableFolderUserDataFolderLanguageAdditionalBrowserArgumentsTargetCompatibleBrowserVersionAllowSingleSignOnUsingOSPrimaryAccountUse this event to mutate environment defaults before initialization completes.
Event: CoreWebView2ControllerOptionsRequested
Option model:
ProfileNameIsInPrivateModeEnabledScriptLocaleUse this event to configure profile, private-mode, and script-locale behavior where the backend supports it.
WebViewControl.CoreWebView2EnvironmentRequested += (_, e) =>
{
e.Options.Language ??= "en-US";
e.Options.UserDataFolder ??= "./artifacts/sample-webview-userdata";
};
WebViewControl.CoreWebView2ControllerOptionsRequested += (_, e) =>
{
e.Options.ProfileName ??= "sample-profile";
e.Options.ScriptLocale ??= "en-US";
};