手工方式:
前提分別在site collection和Site Feature中啟用Feature:Office SharePoint Server Publishing。比如兩個feature都啟用。
由於此Feature建立了Pages library。
如果此Feature沒有啟用,你在設定歡迎頁面的時候,將會收到如下報錯資訊:The site is not valid. The 'Pages' document library is missing.
如果相關的Feature沒有啟用,你將不能看到以上畫面,你可以通過固定的頁面地址來進行訪問。比如:http://Mingle/sites/Lab/_Layouts/AreaWelcomePage.aspx
使用SharePoint物件模型:
using (SPSite site = new SPSite("http://sharepoint.com")) { using (SPWeb web = site.RootWeb) { SPFolder rootFolder = web.RootFolder; rootFolder.WelcomePage = "Pages/HomePage.aspx"; rootFolder.Update(); } }
使用PowerShell:
$SiteUrl = "http://sharepoint.com"$Site = Get-SPWeb -identity $SiteUrl$RootFolder = $Site.RootFolder;$RootFolder.WelcomePage = "SitePages/HomePage.aspx";$RootFolder.Update();$Site.Dispose()
PS C:\> $rootFolder.WelcomePage="/person.aspx"
Exception setting "WelcomePage":"The WelcomePage property must be a path thatis relative to the folder, and the path cannot contain two consecutive periods(..)."At line:1char:13+ $rootFolder.<<<<WelcomePage="/person.aspx"+CategoryInfo:InvalidOperation:(:)[],RuntimeException+FullyQualifiedErrorId:PropertyAssignmentException
特別注意:無論是在Powershell中還是在C#代碼中,首頁地址中起始的地方不能使用/。