Set Welcome Page - Office365 CSOM and C#
c#, csom, sharepoint
Solution
How to set Welcome Page via SharePoint CSOM
public static void SetWelcomePage(Web web,string pageUrl)
{
var ctx = web.Context;
var rootFolder = web.RootFolder;
rootFolder.WelcomePage = pageUrl;
rootFolder.Update();
ctx.ExecuteQuery();
}
Usage
using (var ctx = new ClientContext(webUri))
{
SetWelcomePage(ctx.Web, "SitePages/default.aspx");
}
Problem
I'm wanting to set the Welcome Page for my Sharepoint site using CSOM in C#. Essentially what I'm doing is uploading my new welcome page (home.aspx) to either Site Pages or Pages and then I want to change the welcome page to match my newly uploaded page location. I've looked around but a lot of what I've seen is either PowerShell or Server side code. If someone can point me in the right direction I would very much appreciate it.