inset
ASP.NET Supports Mobile Browsers
Feb. 17, 2003

Although smart devices remain Microsoft’s preferred platform for mobile application development, many ISVs and IT planners must produce applications that can be accessed from simpler devices, such as cell phones that rely on the Wireless Access Protocol (WAP). ASP.NET Mobile Controls and the upcoming release of Visual Studio .NET (VS.NET) 2003 further simplify the development of these applications by hiding some idiosyncrasies of the plethora of cell phones and personal digital assistants (PDAs) in use. Standardizing on a single device and developing applications specifically for that device, however, will probably be a better alternative for corporate developers.

ASP.NET Mobile Controls were originally known as the Microsoft Mobile Internet Toolkit (MMIT) and were available as a download from MSDN. With VS.NET 2003, Microsoft has integrated MMIT with VS.NET, thereby making it available to a larger number of developers and simplifying the installation process.

Pitfalls of Mobile Web Development

Developing applications for mobile devices has long been a difficult task, made more so by the sheer number of different devices and capabilities in the marketplace. These differences go beyond simple cosmetics, such as the placement of keys; they also include differences in the way data must be transmitted and formatted.

Some of the problems developers face in developing broad-use applications include the following:

Different markup languages. Unlike desktop browsers, which display Hypertext Markup Language (HTML) documents transmitted over the Hypertext Transfer Protocol (HTTP), mobile devices support a variety of markup languages and protocols. Some newer devices do indeed support HTTP and HTML, but many cell phones in the United States and Europe use the Wireless Markup Language (WML), while many phones in Japan use a dialect of HTML called cHTML.

Different form factors. Differences in the form factors of devices can also complicate development, particularly when using WML. Because WML is a text-only format, users make choices by scrolling through a list of options and pressing a corresponding number on the keypad. In addition, the screen size and number of lines displayed vary considerably between devices, further complicating the task of designing and implementing an application.

Different browser capabilities. Although the PC browser market has basically come down to a single dominant product (Microsoft’s Internet Explorer), mobile browsers are much more fragmented. Even among those that support HTML, the level of support varies. Some support the earlier HTML 3.2 standard, while others support newer extensions; some support cookies (small bits of information stored on the client for retrieval later) while others do not.

This variation in capabilities makes the task of building an application very difficult, particularly for ISVs who, unlike corporate developers, cannot require users to standardize on a device but must instead be able to work correctly on a very large variety of devices.

Mobile Controls Hide Device Differences

With ASP.NET Mobile Controls, Microsoft aims to make building mobile Web applications as similar as possible to building any other ASP.NET Web application. It attempts to accomplish this by building on the Web development tools included in VS.NET.

Familiar Developer Experience

The initial release of VS.NET included a set of commonly used controls for building Web applications with ASP.NET, along with the ability to debug and deploy those applications. These controls range from very simple encapsulations of HTML tags, such as an input field, to more complex controls that include built-in behavior, such as a calendar that allows the user to select a date by scrolling month by month.

ASP.NET Mobile Controls and VS.NET 2003 extend these capabilities with a set of controls specifically designed for mobile devices. Pages are built by dragging controls from a tool palette onto a visual designer included in VS.NET 2003 and are then customized by the developer using any of the programming languages supported by VS.NET, such as Visual Basic, C++, or C#.

In addition to building applications, VS.NET 2003 supports deploying mobile Web applications to a Web server and debugging those applications once installed. Strangely, while VS.NET 2003 includes a Pocket PC emulator with Pocket Internet Explorer, it does not include a WAP device emulator. Developers must access the application through an actual WAP device or obtain an emulator from mobile browser vendors, such as Openwave, or from device manufacturers, such as Ericsson or Nokia.

Run Time Appearance Adapts to Device

When a device accesses a page containing Mobile Controls, ASP.NET uses a three-step process to produce the final output.

Determine the device capabilities. The process begins when the server receives an HTTP request from the device. (In the case of a WAP device, the request is first processed by a WAP gateway, which translates the WAP request to HTTP.) Among other data, the HTTP headers contain a "user agent" string—text that identifies the specific browser and device making the request. ASP.NET then compares that string to a list of devices stored in an XML-based configuration file on the server. This configuration file, which can be modified by developers to support additional devices, identifies the specific capabilities of each device. For example, it identifies that a Nokia 7110 phone has a screen 44 pixels high and supports WML 1.1, while the Nokia 6310 has 45 pixels but supports WML 1.2. This information is then used to load an appropriate set of device adapters—components that will assist in the rendering process. (For an example of this configuration file, see "XML Configuration of Mobile Controls".)

Execute the page. Once the device adapters have been loaded, the ASP.NET page itself and any business logic written by the developer is executed. The business logic might make a database query and update fields of the display with new information, for instance.

Render the page. Once the developer’s code has executed, the page is ready to be rendered for the specific device. Each control on the page works with its device adapter to produce the appropriate output. When rendering to WML, the device adapter may take what was originally designed to be a single page and split it into several pages, automatically adding buttons to the bottom of the page that allow the user to move forward and backward. (For an example of how a complex control like a calendar is transformed into WML, see the illustration "One Application, Two Devices".)

Supported Devices

ASP.NET Mobile Controls support approximately 200 different devices, including the following:

  • Pocket PCs running Microsoft’s Pocket IE
  • Motorola phones with Openwave browsers
  • Handspring Treo and Visor with the Blazer 2.0 browser
  • Nokia phones running a variety of browsers (including Openwave, Symbian Crystal, and Nokia’s own browser).

In addition, the set of devices supported by Mobile Controls is extensible. Because it uses XML-based configuration files, new devices can be included by adding new entries.

Resources

Specific information on ASP.NET Mobile Controls can be found at www.asp.net/mobile.

The complete list of tested devices and emulators is at www.asp.net/mobile/testeddevices.aspx.

Several Microsoft-supported Web sites provide technical information on .NET development in general and ASP.NET in particular, including www.asp.net and www.gotdotnet.com.

The home page for Visual Studio.NET 2003 is msdn.microsoft.com/vstudio/productinfo/vstudio03/default.asp.