Skip Ribbon Commands
Skip to main content

Adrian Fiechter

Aug 29
Mobile Access to Anonymous Office 365 Sites

Update 29.04.2013: This should just work without installing. Microsoft has updated Office 365.

Download: http://www.fiechter.eu/Solutions/Wsp365.MobileAccess.zip

Test: Open http://www.fiechter.eu on your mobile phone

Installation: http://www.fiechter.eu/Lists/Posts/Post.aspx?ID=4

 

When you open for the first time your Office 365 Small Business site from a mobile phone, then you will surprisingly see the office login screen. Normally it's not the preferred behavior that someone with a mobile device can access your site. Also when you are creating anonymous blogs (I will add a solution for that next week) it's not the preferred behavior.

What's the reason for this behavior?

Microsoft has set up the Office 365 web application with the mobile browser configuration. That works well for collaboration. But when you are using anonymous access, then SPRequestModule method HandleMobilePageRequest forces to open sites in _layouts/mobile/* depending where you are. These sites include code that accesses things, where the anonymous user has no access. With this the user is redirected to the office 365 login page.

The objective is to display the start page on a mobile device:

There are many different approaches to achieve this, but by the fact that we have only a limited set of functionality that we can deploy to Office 365 it is a little bit more complicated. I spent many hours in research on how to redirect all users to www.fiechter.eu/pages/defualt.aspx?mobile=0 and figured out the following difficulties (mobile=0 allow rendering the page also on mobile phones):

  1. In some special scenarios when you don't have an .aspx file it's possible to go around the redirect
  2. The default url can be modified over the welcome page parameter of the rootfolder
  3. It's not possible to deactivate the OOB redirect
  4. A redirect in a sandbox solution cannot be done by code

The solution:

Based on the information above I started to figure out a solution that fits in the boundaries of a sandbox solution and I found it J:

To avoid the first redirect a document library (1) is created and the welcome page url (2) is set to the root url of this document library by adding /?mobile=0 the OOB redirect is not executed because there is no .aspx extensions (3).

Example: The document library url is www.fiechter.eu/wsp365/doclib1 then the root page url www.fiechter.eu/wsp365/doclib1/?mobile=0. This special behavior forces the SPRequestModule to not redirect to mobile pages and then loads the file default.aspx in the doclib1. This file is created by the feature activator, but could also be included in a feature module.

Now, we have already our page loaded. But, because it's not possible to do a redirect in a sandbox solution or web part, we have to find a way that the user is forwarded www.fiechter.eu/pages/defualt.aspx?mobile=0, now (4).

To achieve this functionality, the feature activator adds the OOB field URL to the content type of the newly created document library. Then the item associated with the default.aspx file will be modified and the field URL set to www.fiechter.eu/pages/defualt.aspx?mobile=0. Because default.aspx is a file with a list item behind we can now use the OOB publishing control <SharePoint:UrlRedirector runat="server" id="UrlRedirector" /> which redirects the user to the url specified in the field URL.

 

Installation:

Upload and activate the solutions to your Office 365 site. Go to Manage Site Feature and activate the feature Wsp365.MobileAccess RedirectWelcomePage.

 

Added 04.09.2011

The navigation is now always updated, when you save a publishing page. It's done over an Added and Updated event receiver on the list template 10091 which is the Office365 custom page library.

 

http://www.fiechter.eu/Solutions/Wsp365.MobileAccess.zip.

 

Limitations:

This solution has many known and unknown limitations and I am also not sure if it's really supported by Microsoft. At the moment the biggest limitation is that the navigation is not updated. That means that when the user clicks somewhere on the mobile phone, then he receives a login page again. I will try to fix that soon. Otherwise it works also for anonymous blogs J.