RazorSPoint

How to set the WebBrowser Controll to show mobile pages

Sebastian SchützeSebastian Schütze

Did you notice that when you go to the settings oft he Internet Explorer that you can choose if you want a web page to be rendere das a mobile webpage or a desktop web page? This is pretty good because you the resolution oft he windows phones is actually good enough to not show just low resolution websites. But depending on the data that is transfered and the loading speed you maybe want to just see the mobile version of a web page (if available). But what if I want to use the WebBrowser Control in my Windows Phone Application? I have no Settings at all. I can’t even use different Tabs in my Control. This Control ist just giving me the possibility to display web pages in the internet of html files which I have on my phone. Furthermore when you want to display web pages and the web page automatically recognizes your mobile phone then it displays the mobile version of the web page. Maybe you don’t want that. But to easily work around that (or even duplicate the settings in the IE app) you just need to send additional headers to the server. You just say the server „hey I am not a mobile phone and don’t want to have the mobile version. I am a desktop computer“. This means you can actually send header that you are a „Mozilla“ even if you are not. The Header you need to send are the following:

Now when it comes to sending the header in you control just do the following thing:

If you want to get some more Information about sending header in Silverlight just go to the msdn library

<p>Sebastian Schütze is working as a Senior SharePoint Developer since 2017 at Schindler Digital Business and from 2013-2017 as a SharePoint Consultant at Fritz & Macziol. Beforehand he also worked as a trainer for ASP.NET web development in the Microsoft Student Partner Program. His passion is dedicated to Microsoft technologies.</p>

Comments 8
  • prog1
    Posted on

    prog1 prog1

    Antworten Author

    Does not work. Semms to be something wrong with the code snippet.
    For Navigate method I need a Uri object.


    • Sebastian Schütze
      Posted on

      Sebastian Schütze Sebastian Schütze

      Antworten Author

      Thank you I corrected the code snippet and it should work now, I mixed it up with something else and of course you are right. A Uri object is needed for this.

      You can use the snippet now and it should work!


      • prog1
        Posted on

        prog1 prog1

        Antworten Author

        No sorry, still not working. The Uri needs something like this:

        browser.Navigate(new Uri(„http://www.microsoft.com“), null, „Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; XBLWP7; ZuneWP7)“);)“);

        But if there is no exception it does not work anyway. I’m using the emulator, could this be the problem?


        • Sebastian Schütze
          Posted on

          Sebastian Schütze Sebastian Schütze

          Antworten Author

          Yes this is a copy and paste error by me. I fogort something really important. You need to tell of course what kind of header you want to send:

          Just correct to this for the header:

          User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; XBLWP7; ZuneWP7)

          (the other header as well!


          • prog1
            Posted on

            prog1 prog1

            Author

            Great work!!! Thanks a lot!


  • MB
    Posted on

    MB MB

    Antworten Author

    Does this also work for WP8 .. or should i need to change the strings to WP8, IEMobile8 etc…


By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close