API support

CSOM SSOM

Can be deployed under

Site Web

Notes

Web provision is enabled via WebDefinition object.

Both CSOM/SSOM object models are supported. Provision checks if a web site exists, then creates a new web site using provided definition. You can deploy either single web site or a hierarchy of the web sites using AddWeb() extension method and nesting as per following examples.

Examples

GenerateRandomDefinition

return WithEmptyDefinition(def =>
{
    def.Title = Rnd.String();
    def.Description = Rnd.String();


    def.Url = Rnd.String(16);

    def.WebTemplate = BuiltInWebTemplates.Collaboration.TeamSite;
});


                            
Add web

var newCustomerWeb = new WebDefinition
{
    Title = "New customer site",
    Description = "A dedicated site for the customer support.",
    Url = "new-customer-web",
    WebTemplate = BuiltInWebTemplates.Collaboration.TeamSite
};
var newPublishingWeb = new WebDefinition
{
    Title = "Temporary Publishing Web",
    Description = "A temporary punlishing web.",
    Url = "new-publishing-web",
    WebTemplate = BuiltInWebTemplates.Publishing.PublishingPortal
};

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddWeb(newCustomerWeb);
    web.AddWeb(newPublishingWeb);
});

DeployModel(model);


                            
Add multiple webs

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddWeb(DocWebs.News);
    web.AddWeb(DocWebs.AboutOurCompany);
});

DeployModel(model);


                            
Add hierarchical webs

var model = SPMeta2Model.NewWebModel(web =>
{
    web
        .AddWeb(DocWebs.News)
        .AddWeb(DocWebs.Departments, departmentWeb =>
        {
            departmentWeb
                .AddWeb(DocWebs.DepartmentWebs.HR)
                .AddWeb(DocWebs.DepartmentWebs.ITHelpDesk, itWeb =>
                {
                    itWeb
                        .AddWeb(DocWebs.DepartmentWebs.ITHelpDeskWebs.Apple)
                        .AddWeb(DocWebs.DepartmentWebs.ITHelpDeskWebs.Cisco)
                        .AddWeb(DocWebs.DepartmentWebs.ITHelpDeskWebs.Microsoft);
                })
                .AddWeb(DocWebs.DepartmentWebs.Sales);
        })
        .AddWeb(DocWebs.AboutOurCompany);
});

DeployModel(model);