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
Similar Posts
- How to create an Http Handle to re write the URL
- Handling security for Flex and Silverlight in ASP.NET
- Cross domain request in Silverlight 2.0 beta 2



Comments
Joe Levi on on 12.21.2007 at 5:24 PM
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
eric ramseur on on 7.25.2008 at 6:37 PM
Might want to add ipod to that mix as that will allow for the ipod touch as well as the iphone.