Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

there is a way to activate a control WebView Desktop mode and not Mobile mode?

there is a way to activate a control WebView Desktop mode and not Mobile mode?

<WebView x:name= "WebViewApp" ..../>
like image 366
SMM Avatar asked Feb 16 '15 20:02

SMM


1 Answers

The WebView doesn't have an inherent desktop or mobile mode. Whether a site provides a mobile or desktop optimised site is generally based on the User Agent header. You can set this in a WebView by creating an HttpWebRequest with the agent you want and then navigating with WebView.NavigateWithHttpRequestMessage.

If you want to mimic a specific browser mode you can find the user agent it uses at several web sites.

string userAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop) like Gecko"
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(
    HttpMethod.Post, new Uri("http://whatsmyuseragent.com"));
httpRequestMessage.Headers.Append("User-Agent",userAgent);

myWebView.NavigateWithHttpRequestMessage(httpRequestMessage);
like image 135
Rob Caplan - MSFT Avatar answered Oct 19 '22 07:10

Rob Caplan - MSFT