Logo

深入浅出SharePoint——设置站点的默认欢迎页面

photo

2022年05月26日

手工方式

前提分别在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 that is 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#代码中,主页地址中起始的地方不能使用/。
本文为原创文章,请注意保留出处!

热门文章

修复群晖Synology Drive client右键菜单缺失问题 本教程主要解决windows10右键菜单中没有SynologyDrive菜单的问题,整体思路是找到...修复群晖SynologyDriveclient右键菜单缺失问题 作者:Pastore Antonio
1818 浏览量
docker如何查看一个镜像内部的目录结构及其内部都有哪些文件 前言:有时候我们会在docker上下载一个镜像,或者是上传一个镜像到docker上,甚至有时候就是在...docker如何查看一个镜像内部的目录结构及其内部都有哪些文件 作者:Pastore Antonio
1802 浏览量
configure: error: Package requirements (oniguruma) were not met configure:error:Packagerequirements(oniguruma)...configure:error:Packagerequirements(oniguruma)werenotmet 作者:Pastore Antonio
1533 浏览量
Adobe Acrobat Pro 激活 这里记录了一些AdobeAcrobat的激活教程和组件。浏览量:1,685 作者:Pastore Antonio
1531 浏览量
追寻日出,找回自己 为什么我要去追寻日出?其实我是一个很懒的人,每次都起不来,直到有一次我在租房中睡到了大天亮,阳光照...追寻日出,找回自己 作者:Pastore Antonio
1509 浏览量