Share via


SPSite.GetWebTemplates method (UInt32)

Returns the collection of site definitions that are available for creating Web sites within the site collection.

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

Syntax

'Declaration
Public Function GetWebTemplates ( _
    LCID As UInteger _
) As SPWebTemplateCollection
'Usage
Dim instance As SPSite
Dim LCID As UInteger
Dim returnValue As SPWebTemplateCollection

returnValue = instance.GetWebTemplates(LCID)
public SPWebTemplateCollection GetWebTemplates(
    uint LCID
)

Parameters

  • LCID
    Type: System.UInt32

    A 32-bit unsigned integer that specifies the language of the site definitions to return from the collection.

Return value

Type: Microsoft.SharePoint.SPWebTemplateCollection
An SPWebTemplateCollection object that represents the site definitions.

Remarks

The site definitions that are returned by the GetWebTemplates method include site definitions that are available by default, which are installed in the setup directory (\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE) of each server, and those that have been stored in the configuration database through the command-line operation stsadm -o addtemplate.

Note that in a specific scenario, the specified custom site definition is not found. This scenario occurs when the following sequence of actions occur:

  1. Add a solution that consists of site templates and features.

  2. Create a Web application.

  3. Deploy the solution, including deployment of the application DLLs to the bin directory of the newly created Web application.

  4. Create a new site collection that is based on the custom site definition that was deployed to the Web application.

When this sequence occurs, steps 1, 2, and 3 work fine, but when step 4 is called the application does not find the site definition for the newly deployed site. However, if you stop after step 3, then re-run the application and then call step 4 by itself, the proper custom site definition is found without any problems. The original problem is caused because site templates are cached when a new Web application is created. Therefore, if a custom site definition is deployed with a new Web application, it will not be found because it is not yet in the cache.

There are four ways to work around this problem.

  1. Call all the first three steps, as described above, and then re-run the application and call only step 4. This restarts the process and allows the Web application to locate the deployed custom site definition.

  2. Create a console application that creates a site collection using the template for the custom site definition. Then, call the sequence of four steps that are listed above; however, when you come to step 4 (create site collection), load the console executable that you created in a different process and allow it to complete step 4.

  3. Use the Stsadm.exe command in the code itself. In this approach, the Web application is able to locate the newly deployed custom site definition.

  4. Add and deploy the solution manually by using the SharePoint UI, or by using the Stsadm.exe command prompt.

See also

Reference

SPSite class

SPSite members

GetWebTemplates overload

Microsoft.SharePoint namespace