SPWeb.GetAvailableWebTemplates Method (UInt32)
Gets the Web templates that are available for creating subsites beneath the website, based on the specified locale identifier (ID).
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Function GetAvailableWebTemplates ( _
lcid As UInteger _
) As SPWebTemplateCollection
'Usage
Dim instance As SPWeb
Dim lcid As UInteger
Dim returnValue As SPWebTemplateCollection
returnValue = instance.GetAvailableWebTemplates(lcid)
public SPWebTemplateCollection GetAvailableWebTemplates(
uint lcid
)
Parameters
lcid
Type: System.UInt32A locale ID of the web templates to be retrieved.
Return Value
Type: Microsoft.SharePoint.SPWebTemplateCollection
A collection of the web templates.
Remarks
Use the SetAvailableWebTemplates(Collection<SPWebTemplate>, UInt32) and AllowAllWebTemplates methods to modify the set of web templates that are returned by this method.
In some instances, the specified custom site definition is not found because the custom site definition is not yet in the cache. This occurs when the following steps are made to create a new site collection based on the custom site definition:
Add a solution that consists of site templates and features.
Create a web application.
Deploy the solution, including deployment of the application DLLs to the bin directory of the newly created web application.
Create a new site collection based on the custom site definition that was deployed to the web application.
In this sequence, steps 1, 2, and 3 work as expected, but when step 4 is performed, the application cannot find the site definition for the newly deployed site. The issue arises because site templates are cached when a new web application is created.
There are four ways to work around this issue.
Perform the first three steps, restart the application, and then perform step 4. This restarts the process and allows the web application to locate the deployed custom site definition.
Create a console application that creates a site collection using the template for the custom site definition. Then, perform the first three steps that are listed above. Then load the console executable that you created in a different process and allow it to perform step 4.
Use the SharePoint Management Shell in the code itself. The web application is able to locate the newly deployed custom site definition.
Add and deploy the solution manually by using the SharePoint UI, or by using the SharePoint Management Shell.