Want to Load Desktop Version in My Webview Using Uastring

Want to load desktop version in my webview using uastring

It might be that they know you are on a mobile phone because you have Android in the user agent. Try something more desktop browser looking such as:

String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";

Android webview to load desktop view

Web sites use a variety of mechanisms to decide to serve a mobile version of a page; the user agent is just one of them. They may set a cookie or some other piece of state that will always redirect to the mobile page after you've visited once. They might look at screen dimensions and do it that way. It's very hard to say what this particular website is doing. Maybe try clearing cookies?

Are you certain that the UA you have set is a desktop UA that the site recognises as a desktop browser?

Load desktop version WKWebView iOS 9

To help any who find themselves here for an answer.
The solution was

UserDefaults.standard.register(defaults: ["UserAgent" : "Chrome Safari"])

Setting WebView to view Desktop Site and Not Mobile Site

Change the user agent of webview

 String newUA="Foo/"; // Change this to desired UA

like

 String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
mWebView.getSettings().setUserAgentString(newUA);

Xamarin WebView request desktop site

You need to do this per platform

Android

In Android you have to implement a custom renderer. Add this into your Android code:

// this line directly ubleow usings, before namespace declaration
[assembly:ExportRenderer(typeof(WebView), typeof(DesktopWebViewRenderer))]

// this in your namespace
public class DesktopWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);

Control.Settings.UserAgentString = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
}
}

iOS

Xamarin Forms is using UIWebView, so you have to call

NSUserDefaults.StandardUserDefaults.RegisterDefaults(new NSDictionary("UserAgent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"));

some where in your startup code. E.g. in FinishedLaunching of your AppDelegate.



Related Topics



Leave a reply



Submit