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


2 Responses

  1. I would like to see a continuation of the topic

  2. Hello, I have tried using the mobileformsauthentication object, but still can’t seem to get a session started in my mobile device. I used the sample code at this page:
    http://msdn.microsoft.com/en-us/library/system.web.mobile.mobileformsauthentication.aspx

Leave a Reply