locked
Set mobile version in web browser control RRS feed

  • Question

  • Hi everyone

    How can I set mobile version in the web browser control ?

    Thanks

    Thursday, December 6, 2012 9:40 PM

Answers

  • Well that should work.

    I have just tried two different User-Agents with WebBrowser, here is what I have got:

                Uri u = new Uri("http://www.twitter.com");
    
                //wbControl.Navigate(u, null, "User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)\r\n");
                wbControl.Navigate(u, null, "User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)");

    The first (commented) line shows desktop version of twitter.

    Second one shows mobile version. It works.

    Regards,

    Friday, December 7, 2012 9:10 AM

All replies

  • Hi,

    You can take a look here: http://msdn.microsoft.com/en-us/library/ff626636%28v=vs.92%29.aspx

    public void Navigate(
    	Uri uri,
    	byte[] postData,
    	string additionalHeaders
    )

    I think you can try to set proper User-Agent header using additionalHeaders every time you navigate to web site.

    To my opinion this is the only way.

    Regards,

    Andrey

    Friday, December 7, 2012 12:01 AM
  • thanks for the reply.

    I tried to use this

    Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)

    and other but it still appears the desktop version... I also tried with another site and instead appears the mobile version without specifying the user agent

    Friday, December 7, 2012 8:32 AM
  • Well that should work.

    I have just tried two different User-Agents with WebBrowser, here is what I have got:

                Uri u = new Uri("http://www.twitter.com");
    
                //wbControl.Navigate(u, null, "User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)\r\n");
                wbControl.Navigate(u, null, "User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)");

    The first (commented) line shows desktop version of twitter.

    Second one shows mobile version. It works.

    Regards,

    Friday, December 7, 2012 9:10 AM
  • In case anyone else is having this issue, I found a simpler answer.

    Edit the Web Browser Control XAML. Add the property IsScriptEnabled="True"


    Wednesday, June 25, 2014 9:03 PM