Mobile Device vs Desktop RRS feed

  • Question

  • User-531104354 posted
    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!
    Friday, February 13, 2004 3:40 PM

All replies

  • User749486216 posted
    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>
    Monday, February 16, 2004 7:42 PM
  • User-531104354 posted
    Tuesday, February 17, 2004 11:05 AM
  • User-1237466893 posted
    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 SubIf 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
    Sunday, February 29, 2004 5:14 PM
  • User-1392607778 posted
    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
    Monday, March 1, 2004 4:24 PM
  • User-1237466893 posted
    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?
    Thursday, March 4, 2004 3:23 AM
  • User-1237466893 posted
    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 ifThen I tried it again with Elseif hbc.Type = "Sanyo 4900" Thenand it works! Very cool!
    Thursday, March 4, 2004 3:46 AM
  • User-1143650407 posted
    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.
    Sunday, January 8, 2006 6:21 PM
  • User-1237466893 posted
    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).

    Sunday, January 8, 2006 9:51 PM
  • User-1143650407 posted
    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?

    Wednesday, January 11, 2006 10:37 AM