Adding mobile or handheld device support to ASP.net applications


I came across the task of enabling mobile device support for my asp.net application. Thanks to asp.net mobile controls this is not too difficult to manage, however it does not come out of the box with regular asp.net controls, one has to create mobile forms to enable mobile device support. What I ended up doing was to creating the main sections in mobile forms.

One thing to consider for such applications is that if the entry point is a login page then its best to port that to mobile controls as well, one can check if the client is a mobile device by using  

//mobile device check
            if (Request.Browser[“IsMobileDevice”] == “true”)
            {
                Response.Redirect(“~/mobile/login.aspx”);
            }
            else
            {
                Response.Redirect(“~/login.aspx”);
            }

in either the Gobal.ascx session start or page load event for default.aspx , so that mobile devices automatically branch to the mobile forms from the very beginning.

Also make sure that you add mobile/login.aspx  or whatever you mobile login page is to the authentication exclude list if you are using forms based authentication. I used the following statements in my web.config to exlude my login.aspx page from forms authentication.

 <!– exclude mobile login page from forms authentication –>

  <location path=”mobile/login.aspx”>
    <system.web>
      <authorization>
        <allow users=”*” />
      </authorization>
    </system.web>
  </location>

There are various mobile simulators to check if the forms work fine or not, I used Openwave simulator, which turned out to be quite good, you can download it from http://openwave.com.

Few useful links are

http://www.asp.net/mobile/

http://samples.gotdotnet.com/mobilequickstart

http://www.w3schools.com/dotnetmobile/default.asp

http://msdn2.microsoft.com/en-us/library/08e3b0ck(vs.71).aspx

Advertisements

2 thoughts on “Adding mobile or handheld device support to ASP.net applications

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s