Thursday, July 17, 2008

Programmatically uploading site templates to site template gallery

I had a requirement to upload site templates to site collection’s site template gallery using SharePoint object model. See the code snippet below, which will be helpful to upload site templates to site template gallery.

This code uses a configuration file, which has a custom section called “SiteTemplatesSection”. This custom section holds the physical path of each site template.

Friday, July 4, 2008

Programmatically Creating Site Collection in SharePoint

It is possible to create site collections programmatically. The Site Collection creation can be accomplished in the following ways

1) Using SharePoint Object Model
2) Using Central Admin’s Admin Web Service

Creation Site Collection using SharePoint Object Model

See the following code snippet, which uses SharePoint Object Model to create site collection.

Creating Site Collection using Admin Web Service

The Admin Web Service of Central Admin has the following web methods

The following code snippet uses “CreateSite” web method to create a site collection.
After the successful creation of site collection, this web method returns the URL of the newly created site.