Page view counter

Mobile Device vs Desktop

Last post 01-11-2006 10:37 AM by bluekiwi. 9 replies.

Sort Posts:

  • Mobile Device vs Desktop

    02-13-2004, 3:40 PM
    • Loading...
    • Jus55
    • Joined on 01-05-2004, 12:43 PM
    • Posts 148
    • Points 740
    Hi,

    Is it possible to check if request is coming from desktop or from a mobile device and redirect user to desktop or mobile version of your web site?

    Thanks!
  • Re: Mobile Device vs Desktop

    02-16-2004, 7:42 PM
    • Loading...
    • SusanC
    • Joined on 06-10-2002, 8:43 PM
    • Posts 51
    • Points 255
    • AspNetTeam
    The IBuySpy Portal sample has the following example of this functionality.

    <script language="C#" runat="server">

    public void Page_Load(Object sender, EventArgs e) {

    if (Request.Browser["IsMobileDevice"] == "true" ) {

    Response.Redirect("MobileDefault.aspx");
    }
    else {

    Response.Redirect("DesktopDefault.aspx");
    }
    }

    </script>

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thanks
    -Susan
  • Re: Mobile Device vs Desktop

    02-17-2004, 11:05 AM
    • Loading...
    • Jus55
    • Joined on 01-05-2004, 12:43 PM
    • Posts 148
    • Points 740
    Thanks!
  • Mobile Device redirect fails

    02-29-2004, 5:14 PM
    • Loading...
    • xStrongTowerx
    • Joined on 02-08-2003, 2:28 PM
    • Chico, CA
    • Posts 85
    • Points 358
    I'm trying to do a redirect for mobile devices.

    My phone is using NetFront v3.0 for Sprint PCS

    Here's my code
      Public Sub Page_Load(sender as Object, e as EventArgs)
    

    If not isPostBack Then

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' If Netscape, redirects to non-layers version of the page (default_NN.aspx) if not
    ' there already.

    Dim hbc as HttpBrowserCapabilities = Request.Browser
    If Request.Browser( "IsMobileDevice" ) = True then
    Response.Redirect( "MobileDefault.aspx" )
    Else
    Dim strPath as String
    strPath = Request.FilePath()
    If strPath.IndexOf("_NN") = -1 and hbc.Browser = "Netscape" then
    Response.Redirect( "default_NN.aspx" )
    End if
    End if
    End if
    End Sub
    If I use the OpenWave SDK browser emulator, it redirects me to MobileDefault.aspx. But when I test it on my phone, it redirects me to default_NN.aspx instead. I can't figure this one out. Could it be a caching problem since I didn't change the code until today?

    Aaron
    _lord_design
  • Re: Mobile Device redirect fails

    03-01-2004, 4:24 PM
    • Loading...
    • doswald
    • Joined on 03-01-2004, 1:40 PM
    • Posts 4
    • Points 20
    Aaron,
    I believe that for your phone to be identified it must be defined in the list of supported (mobile) devices. This list is available at http://www.asp.net/mobile/testeddevices.aspx?tabindex=6

    You can add support for unknown devices by generating entries in the machine.config file. A tool to profile your device is available at http://www.asp.net/mobile/profile/default.aspx (but I have never run it).

    If a device is not in the supported list, Request.Browser("IsMobileDevice") returns false.

    From my research it appears that both the phone model and the browser need to match with the list of supported devices for things to work as planned.

    This leads me on to a question for the originator of this thread - Jus55. In early January you were looking for a profile for a BlackBerry 6700 (http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=438832) .

    I was wondering if you ever had any success with your search, did you develop your own or give up?

    Cheers

    Colin
  • Re: Mobile Device redirect fails

    03-04-2004, 3:23 AM
    • Loading...
    • xStrongTowerx
    • Joined on 02-08-2003, 2:28 PM
    • Chico, CA
    • Posts 85
    • Points 358
    I created my profile for my Sanyo 4900 and added it to the web.config file. But the "IsMobileDevice" redirect still does not recognize this device as a mobile device. Apparently it sees the NetFront browser as a version of Netscape (Mozilla). How can I get it to redirect this device to the mobile version of the page?
    _lord_design
  • Re: Mobile Device redirect fails

    03-04-2004, 3:46 AM
    • Loading...
    • xStrongTowerx
    • Joined on 02-08-2003, 2:28 PM
    • Chico, CA
    • Posts 85
    • Points 358
    SWEET!!! It works now!

    I noticed that my web.config profile includes the information
        Browser="NetFront"
    So I went ahead and included this in my Sub Page_Load:
    	  Dim hbc as HttpBrowserCapabilities = Request.Browser
    
    Dim strPath as String
    strPath = Request.FilePath()
    If Request.Browser( "IsMobileDevice" ) = True then
    Response.Redirect( "MobileDefault.aspx" )
    Elseif hbc.Browser = "NetFront" Then
    Response.Redirect( "MobileDefault.aspx" )
    End if
    Then I tried it again with
    	  Elseif hbc.Type = "Sanyo 4900" Then
    and it works!

    Very cool!
    _lord_design
  • Re: Mobile Device redirect fails

    01-08-2006, 6:21 PM
    • Loading...
    • bluekiwi
    • Joined on 04-28-2005, 2:45 PM
    • Posts 315
    • Points 1,459
    Did you have "option strict off" when coding that? Visual Studio 2003
    complains with that code!

    Also why not just go straight through and check for the browser name?

    Great that it works for you, but logically it doesn't make sense.

    If the "IsMobileDevice" check fails, it still opens the mobile web page.

    I gather that I need to add my device's details to machine.config in order for
    the browser id info to be read correctly?

    Like to read other opinions on the above code.
  • Re: Mobile Device redirect fails

    01-08-2006, 9:51 PM
    • Loading...
    • xStrongTowerx
    • Joined on 02-08-2003, 2:28 PM
    • Chico, CA
    • Posts 85
    • Points 358
    Dear Blue Kiwi:

    Sorry, I haven't worked on that particular project in 2 years, and I no longer have reason to, being that I don't have that phone anymore, and my current phone is a pre-paid one that doesn't support browsing any websites other than the ones set up by the provider (i.e. mtv & vh1 -- it's Virgin Mobile).

    xSTx
    _lord_design
  • Re: Mobile Device redirect fails

    01-11-2006, 10:37 AM
    • Loading...
    • bluekiwi
    • Joined on 04-28-2005, 2:45 PM
    • Posts 315
    • Points 1,459
    If you can remember it, pls show me the code entry for web.config. I want to add the NetFront 3 browser for browser detection.

    Do I need to do anything in machine.config?

    Thanks.
Page 1 of 1 (10 items)