SharePoint 2010 Publishing Sites and Mobile Views Authentication Issue

We recently faced an issue with our SharePoint Internet Portal. The Site was published on Internet, but when browsed on Mobile phones, especially Iphone. Whenever you browsed the portal through a mobile device, its throws the authentication window, where you need to provide user id and password.

By default, making a site in SharePoint anonymous not works for mobile users. But this is a very common requirement for Internet Facing web sites, meaning we cannot use SharePoint for Internet? As I started googling, I came to this msdn discussion which concluded same, but there should be some way. There is saying, “Where there is a will there is a way” and there is a way:).

Disable ViewFormPagesLockDown feature from your site collection, since it is by default enabled on publishing sites. Lockdown mode is a feature that you can use to secure published sites. When lockdown mode is turned on, fine-grain permissions for the limited access permission level are reduced. When this feature is enabled, it stops anonymous users accessing any of the layout pages. In case of mobile view, when auser accesses Intranet site,  SharePoint redirects the user to /_layouts/mobile/mblwp.aspx to determine the correct rendering template to be applied. Since it is an application page, LockDown mode will not let the anymous user access the page and he/she will get 401 unauthorized.

Now you know the solution for this, disable the ViewFormPagesLockDown using below powershell command, re-apply permissions (enable anonymous access) and finally recycle IIS to be on safe-side.

Disable-SPFeature -Identity "ViewFormPagesLockDown" -URL http://internet

Here you go!

Update Master Page after update-spsolution

Well if you are a “TRUE” developer, you would prefer to deploy your customizations using SharePoint features rather than backing-up from development and restoring in production environment. So your master pages and css will be part of a feature within a solution package. So what about updates. Will the update-spsolution powershell command update the old master page with the updated one? Yes it will on file system not within SharePoint database, meaning it will not update the master page deployed to a site collection but will be available for the new site collections. So how to update it for the old site collections. You can use powershell deployment script to do the job for you once you have updated the spsolution. Following powershell function will update the master page deployed to a site collection with url $url where $pageUrl is the masterpage URL within the site collection:

function Update-MasterPage([string] $url, [string] $pageUrl)

{

$web = Get-SPWeb $url

$file = $web.GetFile($pageUrl);

$file.RevertContentStream();

write-host “Successfully reverted to definition $($pageUrl)…”

}

You can read master page URLs and Site collection URLs either from a csv or XML. Following function reads master page URLs from a CSV and calls above function:

function Update-MasterPages([string] $url, [string] $csvFile)

{

foreach($page in $data)

{

Update-MasterPage $url $page.Url

}

}

where $csvFile contains the CSV file Path and $url contains Site Collection URL