Create Sub Site in SharePoint using CSOM

The example in this topic show how to use CSOM to Create Sub Site in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  •  
  • using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
  • {
  • WebCreationInformation oWebCreationInformation = new WebCreationInformation();
  • // This is relative URL of the url provided in context
  • oWebCreationInformation.Url = "NewSubSite";
  • oWebCreationInformation.Title = "NewSubSite Site";
  • oWebCreationInformation.Description = "NewSubSite description";
  •  
  • // This will inherit permission from parent site
  • oWebCreationInformation.UseSamePermissionsAsParentSite = true;
  •  
  • // "STS#0" is the code for 'Team Site' template
  • oWebCreationInformation.WebTemplate = "STS#0";
  • oWebCreationInformation.Language = 1033;
  •  
  • Web oWeb = clientContext.Site.RootWeb.Webs.Add(oWebCreationInformation);
  • clientContext.ExecuteQuery();
  • }

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

We value your feedback:

Page URL:

Name:

 

Email:

 
 

Feedback:

 

© 2019 Code SharePoint