Compartilhar via


Identifying Internet Explorer Mobile to a Web Server

4/8/2010

When the browser makes a request to a Web server it sends an HTTP User Agent header. This header is an ASCII string that identifies the browser and its version number. Using this header the server can make decision about the possible formats and limitations of the browser it is sending information to.

The User Agent Header

Originally, the HTTP User Agent headers used by Internet Explorer Mobile were different and depended on the platform. They included both the kind of device and the size of the screen in pixels. For example, Pocket PC for Windows Mobile Version 5.0 and before use the header:

Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)

The original User Agent header for Smartphone for Windows Mobile Version 5.0 and before is:

Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; Smartphone; 176x220)

With Windows Mobile 6.5 the HTTP User Agent header includes identification of the browser. For example, the User Agent header for Windows Mobile 6.5 is as follows:

Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile m . n )

Where m is the major version number and n is the minor version number. This enables a server to provide better information layout.

Interacting with an IIS Web Server

You can use Internet Information Services (IIS) to provide customized views of your Web application based on information that is received from the user's browser. When a browser connects to the Web server, it automatically sends an HTTP User Agent header. The BrowserType object compares the header to entries in the Browscap.ini file. This maps browser capabilities to the HTTP User Agent header.

To identify the mobile Internet browser to an IIS Web Server, add the following lines of code to the Browsecap.ini file on the server.

[Mozilla/4.0 (compatible; MSIE 4.01; Windows CE)]
browser=Pocket Internet Explorer
version=4.1
majorver=#4
minorver=#1
platform=Windows CE
;Specify width of display on target device here.
;This example specifies 240 pixels.
width=240
;Specify height of display on target device here.
;This example specifies 320 pixels.
height=320
cookies=TRUE
frames=TRUE
backgroundsounds=TRUE
javaapplets=FALSE
javascript=TRUE
vbscript=FALSE
tables=TRUE
activexcontrols=TRUE

Interacting with an HTTP Server

For Windows Mobile Professional, the following specific information is included in the HTTP request header when the mobile Internet browser sends a request to an HTTP server.

UA-pixels: {for example, 240x320}
UA-color: {mono2 | mono4 | color8 | color16 | color24 | color32}
UA-OS: {for example, Windows CE (POCKET PC) - Version 4.1}
UA-CPU = {for example, MIPS R4111}
UA-Voice = {TRUE | FALSE}
// Indicates whether device supports voice telephony.

For Windows Mobile Standard, the following specific information is included in the HTTP request header.

UA-pixels: {for example, 240x320}
UA-color: {mono2 | mono4 | color8 | color16 | color24 | color32}
UA-OS: {for example, Windows CE (SMARTPHONE) - Version 4.1}
UA-Voice = {TRUE | FALSE}
// Indicates whether device supports voice telephony.

Identifying a Windows Embedded CE–based Client

The following Active Server Pages (ASP) server-side script identifies a client as Windows Embedded CE–based and sends pages that are optimized for a Windows Embedded CE–based mobile Internet browser.

'Check for Windows Embedded CE.
if (InStr(Request.ServerVariables("HTTP_USER_AGENT"), "Windows CE")) then
   // Add Windows Embedded CE-specific code. 
else
   // Add code for other devices. 
end if

The following client-side script identifies Pocket PC for Windows Mobile Version 5.0 and before devices to the server and requests pages that are optimized for a Windows Mobile–based browser.

// Check for Windows Mobile Professional device.
if (InStr(Request.ServerVariables("HTTP_UA_OS"), "POCKET PC")) then
   { add Windows Mobile Professional specific code }
else
   { add code for other platforms }
end if

The following Microsoft JScript script checks for the presence of Internet Explorer Mobile that has a display size of 240 x 320 pixels.

   var strNav = navigator.userAgent;
// Check for Windows Embedded CE (Windows Mobile powered device,
//           Palm-size PC, Handheld PC, Handheld PC Pro)
   var isCE = strNav.indexOf("Windows CE");
   if(isCE > -1) {
//add Windows Embedded CE specific code
   }
   else {
//add code for other platforms
   }

// Check for Windows Mobile Professional
   var isPPC = strNav.indexOf("240x320");
if(isPPC > -1) {
// add code that is specific to Windows Mobile Professional
   }
   else {
// add code for other platforms
   }

For more information about how to use the browser capabilities in IIS to deliver dynamic, interactive Web pages, see this Microsoft Web site.

See Also

Other Resources

Internet Explorer Mobile Application Development