IsMobileDevice returns false when connecting with WM 2003

S

Sacha Korell

First of all, sorry for cross-posting, but this newsgroup is much busier
than "aspnet.mobile".

I'm trying to create a portal page that redirects depending on the device
that is connecting.

When I use Request.Browser("IsMobileDevice"), it returns false when
connecting with my iPAQ
2215 (and other Windows Mobile 2003 devices), although
HTTPBrowserCapabilities "Platform" returns "WinCE".

What's going on? I'm using VS.NET2003 for development with DeviceUpdate4
installed.

I had a code snippet like (suggested by the MS "Best Practices" page at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmitta/html/bestpractaui.asp):

If Not (Page.IsPostBack) Then
If (Device.IsMobileDevice) Then
RedirectToMobilePage("mobile/m_default.aspx")
Else
Response.Redirect("default.aspx")
End If
End If

It used to work just fine, but now "Device.IsMobileDevice" also returns
false.

Does anybody in this group have a clue why this is happening?

Also, why is has MS not released another device update? The latest one is
over a year old.

Thanks,

Sacha
 
A

Alex Homer

IsMobileDevice is a property of the MobileCapabilities class. You need to
inherit the MobilePage and cast the Request.Browser instance to a
MobileCapabilities instance:

<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="whatever" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>

MobileCapabilities currentCapabilities =
(MobileCapabilities)Request.Browser;
result = currentCapabilities.IsMobileDevice;
 
S

Sacha Korell

That's exactly what I'm doing in my current code. Here's the whole
code-behind:

Public Class check_device
Inherits System.Web.UI.MobileControls.MobilePage
Protected WithEvents Form1 As System.Web.UI.MobileControls.Form

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Dim objCapabilities As System.Web.Mobile.MobileCapabilities

objCapabilities = CType(Request.Browser,
System.Web.Mobile.MobileCapabilities)

If objCapabilities.IsMobileDevice Then
'Redirect to mobile page
Response.Write("Mobile Device")
Else
'Redirect to regular web app
Response.Write("Not a Mobile Device")
End If

End Sub

End Class

This code produces the Response.Write("Not a Mobile Device") when I hit it
with a "Windows Mobile 2003" device. However, when I connect with a "Windows
Mobile 2002" device, it does produce the desired output.

Do you think it might have something to do with server or config settings?

Thanks,

Sacha
 
B

bruce barker

write a test page that displays

Page.Request.ServerVariables["HTTP_USER_AGENT"]

then in the machine.config file update the browsercaps section to support
your iPAQ's useragent string.

-- bruce (sqlwork.com)


| First of all, sorry for cross-posting, but this newsgroup is much busier
| than "aspnet.mobile".
|
| I'm trying to create a portal page that redirects depending on the device
| that is connecting.
|
| When I use Request.Browser("IsMobileDevice"), it returns false when
| connecting with my iPAQ
| 2215 (and other Windows Mobile 2003 devices), although
| HTTPBrowserCapabilities "Platform" returns "WinCE".
|
| What's going on? I'm using VS.NET2003 for development with DeviceUpdate4
| installed.
|
| I had a code snippet like (suggested by the MS "Best Practices" page at
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmitta/html/bestpractaui.asp):
|
| If Not (Page.IsPostBack) Then
| If (Device.IsMobileDevice) Then
| RedirectToMobilePage("mobile/m_default.aspx")
| Else
| Response.Redirect("default.aspx")
| End If
| End If
|
| It used to work just fine, but now "Device.IsMobileDevice" also returns
| false.
|
| Does anybody in this group have a clue why this is happening?
|
| Also, why is has MS not released another device update? The latest one is
| over a year old.
|
| Thanks,
|
| Sacha
|
|
 
S

Sacha Korell

Thanks Bruce, I'll try that. I just thought it should be much easier than
having to hack the machine.config for every new PDA device/OS version. What
happened to device updates from Microsoft?

Sacha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top