Thursday, July 05, 2007

I've needed to expand my automatic redirection script to direct iPhone users to mobile web pages in the same way that I do for Windows Mobile/WAP type devices.

Following Apple's guidelines at  -

http://developer.apple.com/iphone/designingcontent.html

I expanded my automatic redirection ASP.NET page that I blogged about awhile back to include this feature.  Previous post at -   

http://www.binaryrefinery.com/main/default,month,2007-03.aspx#a48c1e6c7-573c-4f68-993e-00aa6f600b7f

Its does the job.   + I am pleased to see that today I have my first iPhone user find my Blog,  I wonder what they think?

 

ASP.NET C# source below -

 

<%@ Page Language="C#" Trace="false" %>

<SCRIPT LANGUAGE="C#" RUNAT=SERVER>

    protected void Page_Load(Object sender, EventArgs e)
    {
        System.Web.Mobile.MobileCapabilities cur = (System.Web.Mobile.MobileCapabilities) Request.Browser;

        

        // this block of code is to detect if users are running Pocket PC 2003/CE or iPhone
        bool isce=false;
        bool isiphone=false;

        try    {
            isce = (Request.UserAgent.IndexOf("Windows CE")!=-1);
            isiphone = (Request.UserAgent.IndexOf("iPhone;")!=-1);
        }
        catch
        {

        }
    
        if (cur.IsMobileDevice||isce||isiphone)
        {                
            Response.Redirect("mobile");  // MOBILE PAGE
        }
        else
        {
            Response.Redirect("main"); // NORMAL PAGE
            
        }
        
        
    }

</SCRIPT>
Thursday, July 05, 2007 3:00:51 PM UTC  #    Comments [0]  | 
Comments are closed.

Theme design by Jelle Druyts

Pick a theme: