Page view counter

Request.Browser.IsMobileDevice

Last post 12-07-2007 3:37 AM by slavik118. 8 replies.

Sort Posts:

  • Request.Browser.IsMobileDevice

    09-07-2006, 4:26 PM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 119
    • Points 350

    I'm building a mobile version of a site that I created in ASP.NET 2.0.  I have the landing page redirect over to the mobile page using

    Request.Browser.IsMobileDevice

     This didn't work for the BlackBerry, so I craeted a check for user agent to redirect correctly.  Now I have noticed that all of the new web enabled phones don't register themselves as mobile devices.  I really need a catch all for any mobile device, regardless if it registers as mobile or not.

     Does anyone know how I can solve this issue?  What should I be looking for in the request parameters.

     

  • Re: Request.Browser.IsMobileDevice

    09-21-2006, 11:50 AM
    • Loading...
    • jamsweb
    • Joined on 09-20-2006, 5:57 PM
    • Posts 71
    • Points 226

    hya i dont know if this will work for you, but have you tried getting the server variable (HTTP_ACCEPT) then check if it contains (application/vnd.wap.xhtml+xml)

  • Re: Request.Browser.IsMobileDevice

    09-21-2006, 1:00 PM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 119
    • Points 350

    I'll give that a try, but I think the problem is that the modern wireless devices make themselves look as much like a regular browser as possible.  This is what's causing me issues is there is no longer a user agent or header that says "yes, I'm a wireless device", at least not one that I have found.

     Thanks for the suggestion though.
     

  • Re: Request.Browser.IsMobileDevice

    09-21-2006, 1:38 PM
    • Loading...
    • jamsweb
    • Joined on 09-20-2006, 5:57 PM
    • Posts 71
    • Points 226

    i tend to agree with you on that ryan. in the past ive used logic similiar to this:

    IF (HTTP_ACCEPT).contains  "text/vnd.wap.wml" THEN (device = WAP 1.0)

     IF (HTTP_ACCEPT).contains "application/vnd.wap.xhtml+xml" THEN (device = WAP 2.0)  ->(newest WAP XHTML mobileprofile)

    IF both of the above are not true THEN (device = WEB browser)

    that is the logic ive used in the past even that does not always work in all situations. so i resorted to making a list of user_agents in my database for the unknown ones. and redirecting as needed.

    if any1 has a good solution on this i would like to know myself. thanx

     

  • Re: Request.Browser.IsMobileDevice

    12-06-2007, 12:53 PM
    • Loading...
    • jgo23
    • Joined on 12-06-2007, 5:52 PM
    • Posts 27
    • Points 25

    I realize this is an old thread, but if anyone is running to the same issue as the OP, you may want to read the following link:

    http://msdn2.microsoft.com/en-us/library/fhhycabe.aspx

  • Re: Request.Browser.IsMobileDevice

    12-06-2007, 1:03 PM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 119
    • Points 350

    Thanks for your reply, but that was the original problem.  Since most modern mobile web browsers don't identify themselves as mobile devices, that code doesn't get the job done.

    I found that most people browsing the site on a mobile device will be using a BlackBerry, so that was the simple solution for me.  Unfortunately, it still doesn't address the underlying problem.
     

  • Re: Request.Browser.IsMobileDevice

    12-06-2007, 2:04 PM
    • Loading...
    • slavik118
    • Joined on 01-17-2006, 12:19 PM
    • Chengdu, China
    • Posts 54
    • Points 253

    You need to detect BlackBerry browser type to address the problem. Try to add following adjustments to the code shown on MSDN:

    <script runat="server" language="c#">
        public void Page_Load(Object sender, EventArgs e)
        {
            if (Request.Browser["IsMobileDevice"] == "true" || Request.Browser["BlackBerry"] == "true" )
            {
                Response.Redirect("MobileDefault.aspx");
            }
            else
            {
                Response.Redirect("DesktopDefault.aspx");
            }
        }
    </script>

  • Re: Request.Browser.IsMobileDevice

    12-06-2007, 2:44 PM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 119
    • Points 350

    I understand how to solve that problem.  What I'm complaining about is it would be nice to have some sort of method like "Request.Browser.IsMobileDevice" actually work correctly and hit all the different mobile browsers.  As it stands now, that method is so far deprecated that it's not worth using.

    I guess with the new world of mobile browsers, mobile friendly web pages will just need to be done through CSS and clean HTML.
     

  • Re: Request.Browser.IsMobileDevice

    12-07-2007, 3:37 AM
    • Loading...
    • slavik118
    • Joined on 01-17-2006, 12:19 PM
    • Chengdu, China
    • Posts 54
    • Points 253
    I agree with you, it would be nice to have a single standard for all mobile browsers. Majority of developers dream of it.By the way, recently I've practiced a new mobile technology that allows building very amazing mobile media portals. It appears that MS Silverlight technology is also on the same way. Nowadays, in some countries you can even view interactive TV with your mobile device. As a matter of fact, interactive video or Flash presentation of some materials to clients will allow you to achieve goals you set in much more quick and efficient way, rather if you opt for plaint text format for this purpose. Moreover, ASP.NET speech technology has also promising prospects in mobile world. Taking into account the fact, that number of mobile users exceeds the number of pc users in times, and some of mobile devices have almost achieved the capability of pc, it will be very difficult to address clients’ needs using just CSS and HTML.
Page 1 of 1 (9 items)