Question Submitted to Google's Matt Cutts Gets a Video Response

by Chris Thursday, September 03 2009

I recently submitted a question to Matt Cutts (Google's Head Webspam Guy) and he responded to the question with a very insightful video.

My question was: "I have a server-side script that automatically redirects visitors to a mobile version of a site if they are using a mobile browser. My question is: What are some things to watch out for (if any) when serving different content based on the visitor?"


http://www.youtube.com/watch?v=hK6wf7CBYS8


Cool stuff!


Tags: , , ,

Google | Search Engine Optimization (SEO)

UPDATED: Mobile Web Browser Detection and Redirection in C# for ASP.net

by Chris Saturday, July 25 2009


Here is an updated version of the mobile web browser detection and redirection in C-Sharp (#C) for ASP.net. For this to work best, you should add it to the "Application_BeginRequest" event of the global.asax file, located in the root directory.

If you use it, please digg it, tweet it, or link to it. That's all we ask. Thanks!



//mobile device detection and redirection
if (Request.Headers["User-Agent"] != null)
{

     if (Request.Browser["IsMobileDevice"] != null && Request.Browser["IsMobileDevice"] == "true")
     Response.Redirect("http://mobile.abwebsitedesign.com");
           
     if (Request.Browser["BlackBerry"] != null && Request.Browser["BlackBerry"] == "true")
     Response.Redirect("http://mobile.abwebsitedesign.com");
           
     if (Request.UserAgent.ToLower().Contains("iphone"))
     Response.Redirect("http://mobile.abwebsitedesign.com");

     if (Request.UserAgent.ToUpper().Contains("MIDP") || Request.UserAgent.ToUpper().Contains("CLDC"))
     Response.Redirect("http://mobile.abwebsitedesign.com");       

}


 

Tags: , , , ,

ASP.net | Microsoft

Mobile Web Browser Detection and Redirection in C# for ASP.net

by Chris Sunday, July 19 2009
UPDATE: We have recently changed the code which we use on our website. It is a little cleaner and more complete. To see the newest version, check out our latest post on mobile web browser detection and redirection in C-Sharp (C#) for ASP.net.

If you wish, however, you can still use the code on this page, which will work just fine.

Adding server-side browser detection and redirection to your website using the ASP.net platform and C# (C-Sharp) is actually quite easy. Below, you will see the code which we have implemented on our site. Though it may not catch ALL browsers (because there are a heck of a lot of them), it will catch most.

This code should be inserted into the Page_Load event of the codebehind file (e.g., samplepage.aspx.cs). To enable this site-wide, just add it to the Page_Load event of the Master Page file.

if (Request.Headers["User-Agent"] != null && (Request.Browser["IsMobileDevice"] == "true" || Request.Browser["BlackBerry"] == "true" || Request.UserAgent.ToUpper().Contains("MIDP") || Request.UserAgent.ToUpper().Contains("CLDC")) || Request.UserAgent.ToLower().Contains("iphone"))
{
Response.Redirect("http://mobile.abwebsitedesign.com");
}


The preceding code will allow you to add as many User Agents as you wish by just adding additional Request.UserAgent properties. The else statement is not necessary in this case, because we want the page to load normally, unless the UserAgent is not a standard browser.

If you wanted to redirect to a certain page for either case, you can do something similar to the following as well:

if (Request.Headers["User-Agent"] != null && (Request.Browser["IsMobileDevice"] == "true" || Request.Browser["BlackBerry"] == "true" || Request.UserAgent.ToUpper().Contains("MIDP") || Request.UserAgent.ToUpper().Contains("CLDC")) || Request.UserAgent.ToLower().Contains("iphone"))
{
Response.Redirect("http://www.abwebsitedesign.com/mobile.html");
}
else
{
Response.Redirect("http://www.abwebsitedesign.com/standard.aspx");
}


Tags: , , , ,

ASP.net | Microsoft

About this Blog

This is a blog about web design and all things that are related to web design. Pertinent and relevant comments and/or questions are highly encouraged, but please be courteous and thoughtful of others whilest making comments.

If you have benefited from a post, please do the right thing and promote it. You can do this by linking to it, tweeting it, or digging it.

Thank you much.

Recent Comments

Comment RSS