ASP.NET Tutorial - An introduction to ASP.NET Mobile - Issue#1

in utopian-io •  7 years ago  (edited)

What Will I Learn?

Learn how to programming ASP.NET for mobile devices application and sites. In This tutorial also learn about -

  • ASP.NET Mobile development tools
  • Mobiles and Web Constraints
  • Authentication Processes
  • Sessions

Requirements

  • ASP.NET
  • ASP.NET Mobile development tools

Difficulty

  • Basic

Tutorial Contents


1 . ASP.NET a framework adapted for mobiles.


The ASP.NET framework provides support for mobile devices that was not managed by his predecessor ASP. This feature is implemented in the game "Microsoft Mobile Internet Toolkit (MMIT)". Although Mobile Internet Toolkit is integrated into the framework in version 1.1, it has an independent versioning.

This part of the framework has nothing to do with the "Compact Framework" that allows to develop for Windows CE.

In the unavoidable namespace "System.Web.UI.WebControls", ASP.NET proposes to many classes common to web development. Of himself the namespace "System.Web.UI.MobileControls" corresponds to the dedicated classes mobile devices and implemented in Mobile Web Forms Controls. These classes support many devices. The code of the application .NET developed with these classes is the same for all mobile customers. The support of the specification of a device (format, browser, number of lines in the display, size of the screen ...) is processed via the "Machine.config" file which indexes the different USER_AGENT of devices managed by the framework. Via this ASP.NET file detects what is the client device. This specialization can be extended. The output formats currently implemented are: Html 3.2 dedicated to PDA, cHTML for i-mode phones (japan) and Wml 1.1 for WAP.


2 . ASP.NET Mobile development tools


Whatever the development tool used, the development visual WYSIWYG is not really possible in this type of development. Indeed because of the wide variety of client devices, it is difficult to standardize rendering.

i)Microsoft Visual Studio .NET:

integration with the system is complete (web server, languages ​​"#", filter / adapter,emulator) with the help services of the Mobile Internet kit Designer (included in MMIT). It is currently the tool the more complete for develop ASP.NET Mobile applications.

ii)Microsoft Webmatrix :

The version 0.6 includes the language support C #, J # and Visual Basic as well as access to SQL data Server / MSDE / Access. This free editor permit to develop ASP.NET Mobile applications .

iii)Borland Delphi.NET:

with the version Delphi 8.Net the creation of form and ASP.NET control Mobile is not proposed. Taking in charge of development ASP.NET Mobile is not complete. In visual design, the Delphi IDE does not do not recognize type checks mobile and produces a error. This mistake is related to the part visual design. The compilation is nevertheless correct.


3 . Mobiles and Web Constraints


The requirements of a system suitable for mobile devices are numerous and complex depending on (or) target device (s).

3 .1 Detection and redirection of a typical customer"mobile device"

Redirection to a page depending on a device type (Desktop or Mobile) is not integrated framework. A website with a part accessible to customers connecting with a mobile device needs take this need
explicitly support in the code. The parameter of config.web file "useFullyQualifiedRedirectUrl" defaults to true is necessary for some Mobiles.

Example of standard code included in the page by default of the site and allowing to do this redirection :-

procedure TWebFormDefault.Page_Load (sender:
System.Object; e: System.EventArgs);
begin
 if (Request.Browser ['IsMobileDevice'] =
'true') then
Response.Redirect (DEFAULT_MOBILEINDEX)
 else
Response.Redirect (DEFAULT_DESKTOPINDEX);
end;

In the case of processing a PostBack, it is necessary to use the "RedirectToMobilePage" method of MobilePage.

3.2. Authentication

ASP.NET provides three configurable authentication modes in the web.config file of the site: the mode of authentication by form, windows and passport. Authentications specific "to the Windows world" are usually not implemented by mobile devices. On IIS "Anonymous" and "Basic" authentication (login / password in clear) generally functioning. By cons authentication NTLM is an in decryptable mumbo jumbo for mobiles.

In the config.web file of the site, the authentication section allows you to specify the mode authentication used by the site.
In general, form authentication is used:

<authentication mode = "Forms">
<forms name = ". ASPXAUTH" loginURL = "logon.aspx"
protection = "All" timeout = "60" />
</ Authentication>
3.3. Session

Ideally located on the server, the session is linked to the client configuration. For example, a browser that does not accept not persistent cookies will pass the authentication state the time of a query. The following query, the cookie not present (since refused), will no longer index this client as authenticated ...
This limitation is even more pronounced for mobiles. The cookies are not supported by mobile devices like cell phones. ASP.NET integrates a advanced setting of different session modes. In the <system.web> section of the configuration file sessionState section tells the framework how this is managed. Here are the different possible parameters:

AttributeValueDescription
Mode"InProc"ou "Stateserver"ou "SQLServer"- "in-process" - persistent: "stateserver"or "SQLServer".
cookieless"true"- no cookie in management of session.
timeout10- fence automatic after 10 minutes of inactivity..

example of cookie-free configuration with a 10 minutes timeout:-

<sessionState mode="InProc" cookieless="true"
timeout="10"/>

ASP.NET allows to work with mobiles without having to develop a particular session management as it was still necessary with ASP and session management via url type "Url? SessionId = ad1j8k7bbjhoo12871". It should be noted that for a session maintained without cookie, the url presented to the customer is prefixed session ID.

Attention, problems of automatic restart of the application ("recycling") are referenced in different
situations for example when browsing the tree with a anti-virus (http://support.microsoft.com/default.aspx?scid=kb;enus;324772 or http://support.microsoft.com/kb/316148/EN-US/).

In this situation, with the "InProc" mode, the data session are reset and thus lost! The resolution classic is persistent storage (Stateserver or SQLServer) of the session. For example, in "StateServer" mode via the service ASP.NET State Service by adding the attribute "StateConnectionString" indicating which server is used:

session storage via the "ASP.NET State" service :-

<sessionState mode="StateServer"
stateConnectionString="tcpip=localhost:42424"
 cookieless="true" timeout="10"/>
3.4. View State

With ASP.NET, the state of the pages is automatically saved in a VIEWSTATE area. This information area is posted to the client. VIEWSTATE may be important, usually mobile device capabilities are not enough to manage this information. The characteristics of the customer (s) target (s) determine the choice of using this feature integrated.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

  1. End-user focused tutorials must address a minimum of three substantial concepts that are unique to the Open Source project and essential learning requirements for end-users. Your tutorial is just a collection of information and not organized in a way so as to make learning easy.

  2. You inform that the tutorial is meant for basic knowledge users, then you go on to write

"In the unavoidable namespace "System.Web.UI.WebControls", ASP.NET proposes to many classes common to web development. Of himself the namespace "System.Web.UI.MobileControls" corresponds to the dedicated classes mobile devices and implemented in Mobile Web Forms Controls."

The user must know about what are classes, objects etc. which means the knowledge expected is atleast indermediate.

  1. The tutorial tries to achieve to much and ends up as an overview of technologies rather then teaching something.

You can contact us on Discord.
[utopian-moderator]