Set Default Page in SharePoint using CSOM

The example in this topic show how to use CSOM to Set Default Page in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  •  
  • using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
  • {
  • // Specify Server relative URL of the page, you want to set as Home page
  • string serverRelativeUrl = "SitePages/NewHomePage.aspx";
  •  
  • clientcontext.Web.RootFolder.WelcomePage = serverRelativeUrl;
  •  
  • clientcontext.Web.RootFolder.Update();
  • clientcontext.ExecuteQuery();
  • }

Thank you for reading this article. This code was tested in SharePoint 2013


© 2019 Code SharePoint