In the mobile world we are coming across different variety of mobile devices like some mobiles are capable to render rich graphics, few are able to render low quality graphics and others capable to display text only. Developing application targets to these devices are became a nightmare (prior to DotNet mobile development), developers were writing additional code to render same application for different devices and it was not so easy to do. Now .NET mobile development makes the work more easier and relax the developers from understanding the target mobile device capability and gives guarantee to run the same application under different mobile platforms without writing any additional code. But again the question is HOW IS IT POSSIBLE? Well the short answer is everything is possible in DotNet and long answer you need to understand the flow of communicating and rendering process between the web application and mobile devices.
This article gives you a clear idea how the same web application (DotNet based) rendering differently based on device capability for example a mobile web page (lets call it as "birthday tracker") contains a calendar control to track birthday, if your mobile device capable to displays high graphics then you will see the calendar control in your mobile screen or if not the same control will display according to its capability (may be in a text format) and the interesting point is developers are relax from writing additional code to make the application compatibility with the target device. Checking the type of target mobile device, its capability and making the application compatibility for the mobile devices is the responsibility of DotNet, developers need to focus only on the functionality. Lets explore how DotNet detecting, converting the data and rendering based on device capability.
The main advantage of DotNet mobile application controls ( placed on web page) are render itself automatically based on the mobile device capability. This process involves two major components.
- ASP.NET Mobile Control : These controls are very much familiar to us like button,text box etc and specially design to work with mobile devices.
- Device Adapter : The prime job of the adapter is generates outputs from the controls and map to markup language which the device can understand such as HTML, cHTML, WML and XHTML
These Two component works together to process the rendering the same application's data in multiple devices. At present DotNet supports 200+ mobile devices, configuration of these devices are define in machine.config file.
Now examine a case study how it works when you are requesting a web page from a PocketPC (PDA). PocketPC will communicate with web server through HTTP request. This request will process in three stage. The First stage involve in identify the type of device in this case a PocketPC and its capability like image, browser capability and types of markup language supports, the information about the device capability is configure in Machine.config file and the web application refers machine.config to identify the device capability and other information about device. If we look at the HTTP request coming from a mobile device contains three major section like URL,User Agent and Header Information as illustrate below.
[Figure 1: Process involves in browsing web page from PocketPC ]
The User Agent string contains the device info and this string will scan with machine.config to identify the details about the requested mobile device. The URL section contains the requested page. Once the page identify application server looks for the instance of the requested page. If the requested page is not yet instantiated then the requested web page (.aspx) will first parse then compiles by the compiler and then the compiled page stores in assembly cache finally server will create a new instance of the cached page. The parsing and compile process is one time activity the subsequent request for the same page will be instantiated from the cache irrespective of any mobile devices. This process leverage the performance of accessing of mobile web page.
The Second stage involves in page rendering process. Once the page has instantiated the controls (mobile controls) of the page also instantiated and the execution process starts based on the user's inputs. After the execution the data has to be render based on the device capability, this is taking care by the device adapters associated with the device and controls. The device adapters generate markup language compatibility with the device for the output in this scenario HTML output and send it to the device (PocketPC).
Now lets examine another case study how it works when you request a page from a cell phone. In this scenario the cell phone mobile browser sends the WAP request to WAP gateway. This gateway provided by the cell phone service providers as illustrate below.
[Figure 2: Process involves in browsing web page from cell phone ]
Now the WAP gateway translate this into a HTTP request and passes it web server over internet. The HTTP request contains URL, User Agent and Header Information, the process of execution the page is same as we discussed earlier in our case study for PocketPC. The main point is instead of generate a HTML output now its generates a WML output because cell phones mobile browser can understands only WML. Once the WML output has generated web server send the output as HTTP response to the WAP gateway and WAP gateway translate it to WAP response and pass it to cell phone.
This is how the mobile web application working in different mobile devices. The DotNet mobile development makes our work very flexible and leverage productivity .Microsoft is doing lots of enhancements in mobile development because today's business running on mobile. I am going to update you all about mobile development in my coming articles.