Friday, October 3, 2014

Server Error in ‘/’ Application when you open Page layouts and site template from SharePoint 2010 site settings.



Server Error in ‘/’ Application when you open Page layouts and site template from SharePoint 2010 site settings.
Issue:
From Site settings Page layouts and site templates link above throws the error shown below:
The UI will display the following error
Fire off your ULS Viewer you will see the following

Notice these lines
at Microsoft.SharePoint.Publishing.PublishingWeb.get_DefaultPageLayout() 
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaTemplateSettingsPage.InitializeDefaultPageLayoutSection()  
Resolution
It means that that the default page layout could not be loaded. The  following powershell script code solved this issue for me.

Add-PSSNapin Microsoft.SharePoint.PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$site = Get-SPSite http://yourserver
$publishingSite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($site.RootWeb)
$pageLayout = $publishingWeb.GetAvailablePageLayouts() | ? { $_.Name -eq "BlankWebPartPage.aspx" }
$publishingWeb.SetDefaultPageLayout($pagelayout, $true)
$publishingWeb.Update()

Ref: http://www.justinkobel.com/post/2014/01/02/Error-in-SharePoint-Publishing-Sites-For-Default-Pages.aspx

I hope this will save you some valuable time.