Handling Device Diversity with

childlikenumberSecurity

Nov 5, 2013 (3 years and 11 months ago)

75 views

Handling Device Diversity with
ASP.NET 2.0 Mobile
Pranay Sharma
Abstract
The intent of this paper is to showcase the capabilities of ASP.NET 2.0 Mobile
to address the problem of device diversity. The mobile devices today support
different markup languages, form factors, device capabilities, and browsers,
this white paper is intended to showcase how ASP.NET 2.0 Mobile addresses
these challenges with the help of Mobile server controls.
For more information, Contact
askus@infosys.com
June 2009
2
|
Infosys – White Paper
Introduction
Overview
In December, 2008 there were about 3.95 billion mobile subscriptions and over 3.05 billion unique mobile phone owners
worldwide (i.e. 46% of the planet’s population)
1
. In January, 2008 there were 1.3 billion internet users worldwide and
out of which 30% users exclusively used mobile as their medium and 33% users accessed net from both a computer and
mobile device2. The figure stood at 825 million mobile internet users in January, 2008, which was about 25% of all the
mobile subscriptions that time
2
. With 3G spreading its reach and 4G round the corner, there seems to be vast potential for
mobile web. Other than this, we know that a high end Mobile costs almost half the price of a desktop. And with significant
improvements in the hardware, input mechanisms such as touch screen interface, and data transport mechanisms, we can
expect the masses to faster adapt to mobile web.
The main challenge in mobile web development is to develop web applications that are compatible with all the handheld
devices. The applications should be intelligent enough to take care of all the variations from mobile to mobile and render web
pages differently for devices depending on the device capabilities.
Challenges in mobile web development
In the last couple of years, especially post year 2000 there has been a meteoric growth of new wireless devices, such as cell
phones, pagers, and personal digital assistants (PDAs). People today have more choices than ever before to pick and choose
the device of their choice, form factor of their choice, brand of their choice etc at the same time , almost all the leading
brands today offer mobiles that are more than just telephony instruments. Web on mobile as we know has picked up and
enabled users to browse Web sites at any time from any location. Developing applications catering to all the above devices is
therefore challenging for the following reasons:

Devices have different hardware configurations like different screen sizes, network connectivity and availability of
different features like phone call facility.

Different devices support different markup languages. Some of them are HTML for PocketPCs, WML for WAP phones,
xHTML, and cHTML.

There are so many different web browsers being shipped with different mobile devices today. All these web browsers
have a different set of features available. They differ in availability of features like cookie support, JavaScript support,
etc.
ASP.NET 2.0 Mobile addresses these challenges by isolating these challenges from the details of wireless development, making
the task easier for the developers to build a single mobile web application that renders appropriately on a wide range of
devices. Thus, developers can quickly and easily build a single mobile web application that delivers appropriate markups for
a wide variety of mobile devices.
Infosys – White Paper
|
3
Web Application Architecture
Mobile Web Application Architecture
3
Fig. 1 Mobile web architecture for both HTTP and WAP based devices
Fig. 2 Detailed flow diagram of a mobile web request.
4
|
Infosys – White Paper
The Mobile web applications can be deployed on the internet in a similar way as normal web applications for desktop are
deployed. When the HTTP request from a mobile web browser comes to the web server, it is processed in three main steps:
Fig. 3 Steps to show how web request is processed on server
The Machine.config schema in the first step applies to all the applications on the server. The Machine.config file has the
hardware information of all the known device platforms available in the mobile market. The HTTP request contains three
components, Url, User Agent string, and the Header string. The User Agent string, which contains information about the
requesting device and its browser, is referred to the elements in Machine.config and reads the details of the device from the
file (Refer to Fig. 2 step 2). This is how the web applications know about the hardware related capabilities of the requesting
device like screen size, preferred rendering type, etc.
To know about the browser details of the requesting browser, the browser name and the browser version which comes with
the User Agent sting is compared with the browser definition files which were introduced in .NET framework 2.0. Similar
to Machine.config, using these “.Browser” files and the User agent string the application comes to know about the browser
details of the requesting browser (Refer to Fig. 2 step 2). These “.Browser” files are available for most of the known browsers.
With AP.NET 2.0 the developers also have the freedom to write their own browser files for a new browser for which the file is
not available.
In the case of HTML based devices the above cycle is followed. But if the request comes from a WML phone, the WAP
request from the device goes to a WAP gateway (Refer to Fig. 1 & 2). These WAP gateways convert the WAP request to a
HTTP request and send the HTTP request to the server. After that the whole procedure repeats itself as in the case of a HTTP
request till the markup creation. The markup created is WML here and is sent back to the WAP gateway as a HTTP response.
At the WAP gateway the HTTP response is converted to WAP response and sent to the device.
This is how the first two challenges described in the section “Challenges in mobile web development” are met.
Infosys – White Paper
|
5
ASP.NET offerings and Mobile Web development
ASP.NET Mobile
The ASP.NET 2.0 for mobile, which was earlier known as Microsoft Mobile Internet Toolkit (MMIT), provides the technology
and tools to build, deploy, and maintain sophisticated mobile applications quickly. ASP.NET 2.0 Mobile also provides tight
integration with Visual Studio .NET which ensures that developers can leverage their existing desktop development skills and
develop mobile web applications. The ASP.NET 2.0 for mobile contains:

Mobile Web Forms Controls
that generate markup language for different devices

Mobile Internet Designer
provides a similar drag and drop development environment on Visual Studio, to develop
applications for mobile as we do for normal web applications

Browser Capabilities
those are rich enough to extend ASP.NET device capabilities to mobile devices
Fig. 4 Mobile web form controls in the toolbar and the IDE
Generating device specific markup at execution time
There are two major ways ASP.NET handles the above mentioned problem:
1.
ASP.NET Mobile server-side controls.
2.
ASP.NET Device Specific control.
A typical mobile web application is a combination of these two mechanisms. In both these cases dynamic markups
are created during execution. And the markup generation is based on different screen sizes, screen orientations, device
capabilities, and browser capabilities. Let us now see how these two mechanisms work.
ASP.Net mobile server-side controls
ASP.NET web server controls follow the Adaptor Architecture provided by the framework. Here each control is rendered
differently to different devices depending on the browser or device making the request.
Whenever, there is a request made from the mobile browser the web server gets to know about the mobile browser and
the mobile device of the incoming request. Based on these details the controls are rendered accordingly for that device and
browser.
6
|
Infosys – White Paper
Fig. 5 Mobile ASPX page with only Mobile server controls
Fig. 6 Example showcasing two different UIs of the same page on a Pocket PC and a WML device
ASP.Net Device Specific control
5
There is one Device Specific container control provided for ASP.NET mobile development. Within a single Device Specific
control we can have different views of a single mobile page. Only a single view will be displayed on a single mobile device,
depending on the capabilities identified for that device. All these different views are configured by specific Device Filters. A
Device Filter defines for which device capability that particular view will be rendered. There can be various filters, some of
them are for specific hardware devices like <isNokia7110>, <isEricssonR380>, etc. and some of them are for categories of
devices like different browsers and different device capabilities. Few of these Device Filters are like <isJPhone>, <isPocketIE>,
<supportsColor>, <supportsCookies>, <supportsJavaScript>.
Infosys – White Paper
|
7
Example:
If we want to have two different views of a mobile page on WAP handsets and HTML supported handsets, we will add two
different templates or views to the Device Specific control on that page. The two views will be configured with the below
given Device Filters.

<
filter
name
=

isHTML

compare
=

PreferredRenderingType

argument
=

html32

/>
<
filter
name
=

isWML

compare
=

PreferredRenderingType

argument
=

wml11

/>
Now, when there is a request from a WAP mobile the view associated with “isWML” device filter is rendered and not the
one with “isHTML” device filter. Refer to Fig 7 and 8 to get more clarity. Another important point is that, normal ASP.NET
controls can also be used within a Device Specific control which is not possible outside a Device Specific control, on a mobile
web form.
Fig. 7 Mobile ASPX page with Device Specific control and two filters attached
Fig. 8 Example showcasing how different DeviceSpecific adaptors are rendered to different devices
8
|
Infosys – White Paper
In the example above, two different views are created for devices supporting HTML and WML markups. The browsers of a
PocketPC and a Wml device is shown to highlight how a single page is rendered differently on two different devices.
This way ASP.NET helps us in creating a single web application to cater to all the web enabled handheld devices.
Device Filters
Device filters are used to define the mobile server controls and Device Specific controls. A Device filter can be applied to a
mobile control and it defines the device capabilities for which that particular control will be rendered.
Advanced Features for mobile web development
Silverlight for Mobile
Microsoft has made rapid progress on the mobile front. Silverlight for mobile is slated to release with WinMo 7 (Windows
Mobile 7) in 2010
7
. Silverlight will provide highly rich web UIs with high quality performance and it will also make the
experiences on mobile and desktop consistent for applications developed on Silverlight. Developers will be able to use the
code of a desktop application and apply it to the application developed for mobile. The mobile application developed will
be consistent through all the supported devices, initially it will be Nokia S60 platform along with Windows Mobile. Mobile
widgets are already there with WinMo 6.5, but Silverlight is expected to change the mobile web experience altogether.
Mobile Device Profiling
6
In the machine.config file we have limited number of devices registered. To create more number of device profiles, there is
this tool available which test all the capabilities of a device and stores it as a file. Once we know the device capabilities of this
new device we can create application for this particular device and add mobile controls supported by this particular device.
Summary
We have seen how ASP.NET 2.0 mobile helps in managing device diversity:

An application built using ASP.NET 2.0 mobile controls can be rendered on any web enabled device.

The developers have got the new found freedom to configure latest devices and browsers to support their web
applications.

Developers can now leverage the dynamic rendering mechanism provided by ASP.NET 2.0 mobile. This has given
them more flexibility to design their web application. With new technologies slated to come from Microsoft in the
coming years like Silverlight, the UI is expected to become more exciting on mobile.

In the days to come we see that with powerful tools it would be fun for the developers to design and develop dynamic
mobile applications.
References
1.
Tomi T Ahonen (December, 2008)
Trillion with a T, the Newest Giant Industry has Arrived: the Money and Meaning of Mobile
.

http://www.communities-dominate.blogs.com/brands/2008/12/trillion-with-a.html
[viewed 02/06/2009]
.
2.
Tomi T Ahonen (December, 2008)
when there is a mobile phone for half the planet: Understanding the biggest technology
.

http://communities-dominate.blogs.com/brands/2008/01/when-there-is-a.html
[viewed 02/06/2009].
3.
Mobile Application Architecture


http://www.asp.net/mobile/architecture/
[viewed 02/06/2009]
.
4.
ASP.NET Mobile Web Development Overview.


http://msdn.microsoft.com/en-us/library/ms178619.aspx
[viewed 02/06/2009]
.
5.
Device-Specific Rendering

http://msdn.microsoft.com/en-us/library/hkx121s4.aspx
[viewed 02/06/2009].
6.
Frank Tse,
Mobile device profiling tool.


http://www.asp.net/Downloads/sandbox/mobile-device-profiling-tool/
[viewed 02/06/2009].
7.
Nickinson, Phil (March 19, 2009)
Silverlight Mobile rumored for WinMo 7


http://www.wmexperts.com/silverlight-mobile-rumored-windows-mobile-65
[viewed 2/06/2009].
About the Author
Pranay
has about 3 years of experience on Microsoft technologies. He has worked on ASP.Net mobile, Compact
Framework and is currently employed with Infosys Ltd as Software Engineer with Microsoft Tehnology Center (MTC).
Acknowledgment
I would like to acknowledge the support provided by the following:
Manish Srivastava

manishsv@infosys.com

Principal Technical Architect, MTC
Sathayanarayana S. V.

sathyanarayana_sv@infosys.com

Senior Technical Architect, MTC
Parag Dave

parag_dave@infosys.com

Senior Technical Specialist, MTC
Their timely reviews and suggestions played an important role in making this paper possible.