SPC366 Making SharePoint Websites Sing on your Smartphone

Well that was fun!

I had a real blast co-presesnting that session with Chris. As promised I have a bunch of resources for you to download and peruse.

Disabling Mobile Re-direction via PowerShell

Hmmm, apparently WordPress won’t let me host any useful file formats in my site (not even plain .txt files!!!) so sorry…. My plans of giving you folks full Visual Studio solutions as zip files has been foiled! I’ll work out a cunning plan to get around this later.

In the meantime:

The custom re-director I showed off was based off this MSDN article: http://msdn.microsoft.com/en-us/library/ms441925.aspx. Essentially you should:

  • Create a mapped folder in you SharePoint Solution, mapping it to 14HIVE\TEMPLATE\LAYOUTS\MOBILE
  • Into this add your own custom aspx page that inherits from Microsoft.SharePoint.MobileRedirection.SPMobilePage
  • Override the OnInit method to provide your custom redirection
  • Create a copy of the existing mbllists.aspx as mbllists.old.aspx, or similar
  • Replace the existing mbllists.aspx with your own custom page that contains:
  • <SPMobile:SPMobileForm RunAt="Server" PageType="HomePage" Paginate="true">
    	<SPMobile:SPMobileHomePageRedirection ID="SPMobileHomePageRedirection1" RunAt="Server" 
        PageFileName="CustomMobileRedirect.aspx" />
  • Deploy the solution

The HttpHandler that I used to trick SharePoint into not re-directing I sourced from the blog of Waldek Mastykarz: http://blog.mastykarz.nl/inconvenient-sharepoint-2010-mobile-redirect/.

I then coupled it with a really simple webpart that contained the following code.

using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;

namespace VariationsRedirector.RedirectWebPart
    public class RedirectWebPart : WebPart
        protected override void OnInit(EventArgs e)
            if (Page.Request.Browser.IsMobileDevice)
                string mobileUrl = GetMobileSiteUrl();

        /// <summary>
        /// Gets the Mobile URL form the config settings list if it exists
        /// </summary>
        /// <returns>The mobile URL</returns>
        private string GetMobileSiteUrl()
            //This is just hard coded to change the URL of the current request,
            //swaping the mobile variation label for the www variation label, 
            //hey, it's demo code...
            string mobileUrl = Page.Request.Url.ToString().ToLower().Replace("/www/", "/mobile/");
            return mobileUrl;

Many thanks to the Conference team for allowing me to present and to all of you that came along to my session
Feel free to reach out to either Chris of myself if you have any further queries 🙂

This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to SPC366 Making SharePoint Websites Sing on your Smartphone

  1. Hi Gavin
    Great presentation this week. I made a note to myself to come here and have a look at the HTML, CSS etc. from your demos. When you get that VS solution zipped and posted somewhere, please let the world know.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.