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