Site.Create Method1
Crea un nuevo sitio web.
Sintaxis
objAppSrv.Get("Site").Create(
SiteName,
Bindings[],
PhysicalPath,
ServerAutoStart
)
var newsite = appsrv.Get("Site").Create(
SiteName,
Bindings[],
PhysicalPath,
ServerAutoStart
);
Parámetros
Name | Descripción |
---|---|
Name |
Cadena que contiene el nombre del nuevo sitio web. |
Bindings |
Matriz de objetos BindingElement. El enlace debe incluir al menos un nombre de host, un puerto o una dirección IP. |
PhysicalPath |
Cadena que contiene una ruta de acceso completa de un directorio físico al que desea asignar el sitio web. |
ServerAutoStart |
Valor opcional boolean . true si la instancia del servidor debe iniciarse automáticamente cuando se inicia el Servicio de publicación World Wide Web (servicio WWW); de lo contrario, false . |
Valor devuelto
Este método no devuelve ningún valor.
Comentarios
Este método reemplaza el método IIS 6.0 IIsWebService.CreateWebSite
.
Nota:
No puede usar Site.SpawnInstance_
ni Site.Put_
para crear un sitio web. Un nuevo sitio debe tener una aplicación raíz y un directorio virtual raíz, y estos solo se pueden especificar a través del método Create
.
Ejemplo
En el siguiente ejemplo se crea un nuevo sitio web.
Nota:
Dado que Create
es un método static
, debe llamarlo mediante la definición Site
.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Specify a name and physical path for the new Web site.
SiteName = "SampleSite"
PhysicalPath = "C:\inetpub\wwwroot"
' Create a Bindings object by using the WMI SpawnInstance_ method.
Set SiteBinding = oWebAdmin.Get("BindingElement").SpawnInstance_
SiteBinding.BindingInformation = "*:80:www.SampleSite.com"
SiteBinding.Protocol = "http"
BindingsArray = array(SiteBinding)
' Get the site object definition
Set SiteDefinition = oWebAdmin.Get("Site")
' Pass the required parameters to the Create method on the Site
' definition to create the site.
SiteDefinition.Create SiteName, BindingsArray, PhysicalPath
Requisitos
Tipo | Descripción |
---|---|
Remoto | - IIS 7.0 en Windows Vista - IIS 7.5 en Windows 7 - IIS 8.0 en Windows 8 - IIS 10.0 en Windows 10 |
Server | - IIS 7.0 en Windows Server 2008 - IIS 7.5 en Windows Server 2008 R2 - IIS 8.0 en Windows Server 2012 - IIS 8.5 en Windows Server 2012 R2 - IIS 10.0 en Windows Server 2016 |
Producto | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 |
Archivo MOF | WebAdministration.mof |