다음을 통해 공유


CoreWebView2Settings.UserAgent Property

Definition

Determines WebView2's User Agent.

public string UserAgent { get; set; }
member this.UserAgent : string with get, set
Public Property UserAgent As String

Property Value

Examples

WebViewSettings.UserAgent = dialog.Input.Text;

Remarks

The default value is the default User Agent of the Edge browser. This property may be overridden if the User-Agent header is set in a request. If the parameter is empty the User Agent will not be updated and the current User Agent will remain. Setting this property may clear User Agent Client Hints headers Sec-CH-UA-* and script values from navigator.userAgentData. Current implementation behavior is subject to change. By default, the User Agent set will also be effective on the Service Worker associated with the WebView. If there are multiple WebViews associated with the same service worker, the last User Agent set will be used. To disable this behavior, disable the feature flag msWebView2SetUserAgentOverrideOnServiceWorker.

Applies to