Al Pascual



Geo RSS
Geo Twitter Timeline

Blogs I read

<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Add support for the iPhone to your ASP.NET pages

So, you realized that many people get to your blog using the iPhone and you want to provide a better interface for people using the iPhone, even knowing the iPhone has the best browser compared to other mobile devices, will be nice to be able to ready the posts without other frames around, just the posts.

To accomplish that I wrote a Http Handler for Community Server, of course you can use it for your own blog even if you are not using CS 2007.

Why a http handler? Well the fastest way to get that working as I can inspect the request and redirect it to the rss feed bypassing the html.

On the request we can do :

public class iPhoneSupport : IHttpHandler
    {
        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.UserAgent.ToUpper().IndexOf("IPHONE") > -1)
            {
                context.Response.Redirect(context.Request.Url.ToString().Replace("default.aspx", "rss.aspx"));
            }
        }

        #endregion
    }

 

So when the user requests the main page for the blog, you can redirect them to the RSS page for better formatting. Will make the life of the iPhone user much easier.

Also you can use Server.Transfer instead of Response.Redirect if you want to hide the URL, but I would recommend to use Response.Redirect.

To register the Http Handler on Community Server:

<httpHandlers>

<add verb="*"

         path="~blog/al/default.aspx"

         type="BlogCalendar.iPhoneSupport" />

</httpHandlers>

Remember the iPhone user loves reading blogs, let's make it easier for them/us.

Cheers

Al

Posted: Dec 20 2007, 11:27 PM by albert | with 8 comment(s)
Filed under: ,

Comments

I Organize » Blog Archive » Add support for the iPhone to your ASP.NET pages said:

Pingback from  I Organize  &raquo; Blog Archive   &raquo; Add support for the iPhone to your ASP.NET pages

# December 21, 2007 1:08 AM

IPhone » Add support for the iPhone to your ASP.NET pages said:

Pingback from  IPhone &raquo; Add support for the iPhone to your ASP.NET pages

# December 21, 2007 1:45 AM

Iphone: Apple Iphone Reviews, Accessories & Gadgets » Add support for the iPhone to your ASP.NET pages said:

Pingback from  Iphone: Apple Iphone Reviews, Accessories &#038; Gadgets &raquo; Add support for the iPhone to your ASP.NET pages

# December 21, 2007 3:38 AM

Joe Levi said:

Isn't the whole selling point behind the iPhone the fact that all the websites in the entire world are right there without any changes at all?! - www.JoeLevi.com
# December 21, 2007 5:24 PM

Hosam Kamel said:

a good article explains the implementation of an ASP.NET handler to add support to iPhone in the ASP

# December 22, 2007 9:04 AM

Scott Hanselman's Computer Zen said:

# June 9, 2008 7:34 PM

eric ramseur said:

Might want to add ipod to that mix as that will allow for the ipod touch as well as the iphone.
# July 25, 2008 6:37 PM