locked
Determinr Mobile Device RRS feed

  • Question

  • User969992919 posted
    Hi What is the best way to determine if device is mobile? Is (isMobile) a good way?
    Friday, June 15, 2012 1:37 PM

Answers

All replies

  • User1014742505 posted

    http://forums.asp.net/p/1155270/1897491.aspx#1897491

    This will provide the answer you are looking for.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 15, 2012 1:44 PM
  • User-1438829842 posted

    You need to understand.. UserAgent you can use this

    http://css-tricks.com/snippets/javascript/redirect-mobile-devices/

    Redirect Mobile Devices

    <script type="text/javascript">
    <!--
    if (screen.width <= 699) {
    document.location = "mobile.html";
    }
    //-->
    </script>

    For iPhones/iPods Specifically

    <script language=javascript>
    <!--
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
       location.replace("http://url-to-send-them/iphone.html");
    }
    -->
    </script>

    Or u can use Page_Load

    HttpBrowserCapabilities Version = Request.Browser;
    if ( Version.IsMobileDevice = true)
    {
     Response.Redirect("yourPage-forMobiles.aspx");
    }
    e;se
    {
     Response.Redirect("yourRealPage-For-PC-Users.aspx");
    }

    Good luck` Mark those Post as Answered if they really helped you.. No matter you can Mark Multiple Post as Answer.

    Friday, June 15, 2012 4:09 PM
  • User-1362038177 posted

    If you do not want to play with UserAgent by yourself, the solution most users use is the 51Degree API.

    Please check it out on the following codeplex project:

    http://51degrees.codeplex.com/

    Friday, June 15, 2012 8:08 PM
  • User71929859 posted

    Hello,

    You can use 

    if(Request.Browser.IsMobileDevice)
    {
       //Code here
    }

    But according to this article, it won't detect some phones. In that case, you can use the solution posted there. 

    Saturday, June 16, 2012 9:07 AM
  • User1943143334 posted

    Hi,

    Check the below link, which provides the code for different languages!

    http://detectmobilebrowsers.com/

    Hope it helps u...

    Saturday, June 16, 2012 10:26 AM
  • User969992919 posted
    If you were given an option, will you choose to do it using UserAgent / isMobileDevice or go for 51degree? What is your advise?
    Sunday, June 17, 2012 10:16 AM
  • User1943143334 posted

    Hi,

    I prefer doing it using UserAgent! I feel it's a feasible option, since UserAgent string can be fetched from JavaScript as well as ServerSice Code!

    Moreover, IsMobileDevice works fine only in ASP.NET MVC4!

    Hope it helps u...

    Monday, June 18, 2012 12:38 AM