This documentation is archived and is not being maintained.

SPCustomWebTemplate Class

Windows SharePoint Services 3

Represents a custom site template.


Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPCustomWebTemplate : SPWebTemplate

You create a custom site template (.stp file) when you save a site as a template in the user interface or through the object model by using SaveAsTemplate() method.

Custom site templates are one of two kinds of foundational entities that can be used to create sites. The other kind is site definition configuration.


While an SPWebTemplate can represent either a site definition configuration or a custom site template, an SPCustomWebTemplate always represents a custom site template.

Use the GetCustomWebTemplates method of the SPSite class to return the collection of site templates created through the user interface or the object model. After you have a reference to a collection, use an indexer to return a single site template. For example, if the collection is assigned to a variable named mySiteTemplates, use mySiteTemplates[index] in Microsoft Visual C#, or mySiteTemplates(index) in Microsoft Visual Basic, where index is either the title or the index number in the collection of the site template.

A site template is defined in a manifest.xml file that is compressed into the .stp file. The file is stored in the SharePoint database. (An .stp file is a CAB file. You can open it in Windows Explorer if you first change the extension to .cab.)

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.