SPSite.GetWebTemplates method (UInt32)
傳回可用於建立網站集合內的 Web 站台的站台定義的集合。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Function GetWebTemplates ( _
LCID As UInteger _
) As SPWebTemplateCollection
'用途
Dim instance As SPSite
Dim LCID As UInteger
Dim returnValue As SPWebTemplateCollection
returnValue = instance.GetWebTemplates(LCID)
public SPWebTemplateCollection GetWebTemplates(
uint LCID
)
參數
LCID
Type: System.UInt3232 位元不帶正負號的整數,指定要從集合傳回的站台定義的語言。
傳回值
Type: Microsoft.SharePoint.SPWebTemplateCollection
SPWebTemplateCollection 物件,表示網站定義。
備註
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:
Add a solution that consists of site templates and features.
建立 Web 應用程式。
Deploy the solution, including deployment of the application DLLs to the bin directory of the newly created Web application.
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.
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.
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.
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.
Add and deploy the solution manually by using the SharePoint UI, or by using the Stsadm.exe command prompt.