Disable Mobile Redirect on Your Public-Facing SharePoint Sites

Sometimes when you try to navigate to a site from a mobile device, you'll be redirected to the SharePoint mobile version of that site. The mobile view is a bit of a throwback to a bygone era. It gives you a restricted text view designed to work on older devices. Nowadays, mobile browsers are much better and you would much rather see the site rendered using responsive design.

Even worse—you might not have access to mobile pages, resulting in the authentication problems. Instead of fiddling with permissions, the best solution is to simply switch off the mobile view entirely. The easiest way to do this is to add a few lines to your web.config file. Add the following to the System.Web element following the SharePoint section that contains your SafeControls. It's normally about a third of the way down the web.config file. Here's the code to add:

<browserCaps>
  <result type="System.Web.Mobile.MobileCapabilities, 
    System.Web.Mobile, Version=2.0.0.0, Culture=neutral, 
    PublicKeyToken=b03f5f7f11d50a3a"/>
  <filter>isMobileDevice=false</filter>
</browserCaps>
  

Here's what that section of your config file should look like when you're finished:

<Action id="68c8f882-0c21-4190-9c85-ec9672bf8c16" 
  sourceFile="C:\Program Files\Common Files\Microsoft Shared\Web Server 
  Extensions\14\config\Webconfig.rs.xml" />
</MergedActions>
</SharePoint>
<system.web>
  <browserCaps>
  <result type="System.Web.Mobile.MobileCapabilities, 
     System.Web.Mobile, Version=2.0.0.0, Culture=neutral, 
     PublicKeyToken=b03f5f7f11d50a3a"/>
  <filter>isMobileDevice=false</filter>
  </browserCaps>
<securityPolicy>
<trustLevel name="WSS_Medium" 
  policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server 
  Extensions\14\config\wss_mediumtrust.config" />
<trustLevel name="WSS_Minimal"
  policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server 
  Extensions\14\config\wss_minimaltrust.config" />
</securityPolicy>
<httpHandlers />
<customErrors mode="On" />
<httpRuntime maxRequestLength="51200" />
<authentication mode="Windows" />
<identity impersonate="true" />

If you want to do this programmatically, you can use the SPWebConfigurationModification class and deploy it as a feature by adding your code to the feature receiver.

Bill Ayers is a consultant developer and software architect who has been working on SharePoint since version 2003, and is a Microsoft Certified Master and MCSM, SharePoint. He specializes in Web content management and intranet portals. He has more than 20 years' experience in the software industry, and speaks regularly at international conferences and user groups. He's also a moderator on SharePoint.StackExchange.com and blogs at SPDoctor.net.

Posted by Bill Ayers on 04/16/2015


Keep Up-to-Date with Visual Studio Live!

Email address*Country*