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#代码中,主页地址中起始的地方不能使用/。

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
所有附件
该文章没有附件.
本文为原创文章,请注意保留出处!

热门文章

WordPress 后台编辑器样式实现直接预览 在WordPress3.0以后,有一个新的实用功能:你可以更改默认后台编辑器(TinyMCE)的样...WordPress后台编辑器样式实现直接预览 作者:Pastore Antonio
1451 浏览量
【干货】Chrome插件(扩展)开发全攻略 写在前面我花了将近一个多月的时间断断续续写下这篇博文,并精心写下完整demo,写博客的辛苦大家懂的...【干货】Chrome插件(扩展)开发全攻略 作者:Pastore Antonio
1415 浏览量
CentOS 编译错误+配置错误解决方法集合 ERROR:theHTTPXSLTmodulerequiresthelibxml2/l...CentOS编译错误+配置错误解决方法集合 作者:Pastore Antonio
1409 浏览量
WordPress中加载JavaScript脚本的方法 在WordPress中加载脚本(为CSS和JS,下同)文件,大多数人的做法是直接在hea...WordPress中加载JavaScript脚本的方法 作者:Pastore Antonio
1385 浏览量
wordpress学习五: 通过wordpress_xmlrpc的python包远程操作wordpress wordpress提供了丰富的xmlrpc接口api来供我们远程操控wp的内容。伟大的开源社区有人就...wordpress学习五:通过wordpress_xmlrpc的python包远程操作wordpress 作者:Pastore Antonio
1382 浏览量