Have SharePoint public site – here is how to make it mobile friendly

SharePoint, especially 2010 release, is becoming more popular as a public site platform – and with an increased number of mobile devices – mobile site experience is expected.

Both SharePoint and SharePoint 2010 have mobile support. When user with a mobile device accesses the site – the site redirects users to a mobile version of the site. In this article we will cover how to make sure that you redirect all of the latest devices to a mobile site as well as how the actual redirect happens.

If you Navigate to the root of your SharePoint site in IIS (Ex. C:\Inetpub\wwwroot\wss\VirtualDirectories\80) you will locate App_Browsers – the folder that contains browser definitions. In order to ensure you have support for all of the latest browsers – you can download the latest browser definition file (mobile.browser) from codeplex – Mobile Device Browser File (credit goes to Mark Bice for this one) .

Now copy the mobile.browser file you downloaded to Devices folder in App_Browsers which you will have to create.

If you worked with ASP.Net before you probably know that HttpContext has a property that will determine whether your browser is a mobile browser – HttpContext.Current.Request.Browser.IsMobileDevice . This will ordinarily return false unless you have an up to date mobile.browser file – so keep your browser definitions current.

What happens next is really up to you. You can create a user control in the masterpage of your SharePoint site; the user control will have a code behind that will determine whether the current browser is a mobile device browser and redirect users to more simplified version of a site.

Here is how my user control code behind could look like:

HttpRequest req = HttpContext.Current.Request;
string pageName = req.Url.Segments[req.Url.Segments.Length - 1];
string mobileUrl = MobileHelper.getMobilePage(pageName);
if (HttpContext.Current.Request.Browser.IsMobileDevice)
{   if (!string.IsNullOrEmpty(mobileUrl))
{        Response.Redirect("~/Mobile/Pages/" + mobileUrl);    }
else    {        Response.Redirect("~/Mobile/Pages/" +
MobileConstants.NotFoundPage);    }   }

Good Luck!

This entry was posted in MOSS, sharepoint, sharepoint 2010 and tagged , , , . Bookmark the permalink.

Comments are closed.