Thursday, March 28, 2013

Default viewnot pointing to AllItems.aspx

Issue:
The landing page  for "Site Pages"/"Pages" library will not be AllItems.aspx. Even if we change the library settings for default view, the change is not committed.

Solution:
In such cases, run the following PowerShell script.

$site = Get-SPSite "http://SITEURL"
$web=$site.OpenWeb()
$list = $web.Lists["Site Pages"]
$rootfolder = $list.RootFolder
$rootfolder.WelcomePage = "Forms/AllPages.aspx"
$rootfolder.Update()
Write-Host $list.RootFolder.WelcomePage
$web.Dispose()

 

Get list of corrupted files from SP Content Database

Issue:
When we try to download a file from SharePoint site, it might take us to error page. We can find the following error in the ULS log:

Background file fill operation caught exception: System.InvalidOperationException: Operation is not valid due to the current state of the object.     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundSqlFileFiller.OnReadComplete(IAsyncResult result) 

System.InvalidOperationException: Operation is not valid due to the current state of the object.    at Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundFileFiller.Fill()     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBuffer.WaitForIntervalFill(SPInterval i)     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedMemoryStream.Read(Byte[] array, Int32 offset, Int32 count)     at Microsoft.SharePoint.SPFileStream.Read(Byte[] buffer, Int32 offset, Int32 count)     at Microsoft.SharePoint.ApplicationPages.Download.WriteStrmToResponse(Stream strm)     at Microsoft.SharePoint.ApplicationPages.Download.WriteFile(String sourceUrl)     at System.Web.UI.Control.LoadRecursive() 

Cause:
The SharePoint content database is having corrupted files.

Solution/Work around:
Run the following query against a content database in SharePoint 2010 (and above) to get the list of corrupted  files:

select * from AllDocs with(nolock) where id in ( select distinct (id) from AllDocStreams with(nolock) where Content =0x )
 
Delete the file(s) and reupload the files. There is no direct way to fix the corruption in the database.