Site Class [IIS 7 and higher]

Represents an IIS Web site.

Syntax

class Site : ConfiguredObject

Methods

The following table lists the methods exposed by the Site class.

Name

Description

Create

Creates a new Web site.

GetAllSections

(Inherited from ConfiguredObject.)

GetSection

(Inherited from ConfiguredObject.)

GetState

Returns the run-time state of a Web site.

RevertToParent

Reverts a Web site configuration value or values to those of its parent site.

Start

Starts an existing Web site.

Stop

Stops a currently running Web site.

Note

The IIS 6.0 WMI IIsWebServer class supported the Continue and Pause methods for a Web site. This functionality is no longer supported in IIS 7.

Properties

The following table lists the properties exposed by the Site class.

Name

Description

ApplicationDefaults

An ApplicationElementDefaults object whose read/write properties contain the default values for applications within a Web site. Individual application settings will override these defaults.

Bindings

A read/write array of BindingElement objects.

Id

A read/write uint32 value that contains the site ID. Site IDs must be unique.

NoteNote:
To avoid binding conflicts, a site that is already running will stop if you change its site ID.

Limits

A read/write SiteLimits object that exposes connection-related limits for a site.

LogFile

A read/write SiteLogFile object that configures logging for a Web site.

Name

A read-only string value that contains the name of the Web site. Site names must be unique. This is the only key property for the Site class.

ServerAutoStart

A read/write boolean value. true if the Web site will start when the World Wide Web Publishing Service (WWW service) starts; otherwise, false. The default is true.

TraceFailedRequestsLogging

A TraceFailedRequestsLogging object that exposes read/write logging properties for the Web site.

VirtualDirectoryDefaults

A read-only VirtualDirectoryElementDefaults object that contains the default values for virtual directories in a site. Individual virtual directory settings will override these defaults.

Remarks

You cannot set the physical path for a Web site by using the Site class. Use the PhysicalPath property of the root VirtualDirectory object instead.

Note

You must set the ApplicationPool property on the root Application object, not on the Site object.

Example

The following example sets the physical path for the default Web site.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Get the root virtual directory for the default Web site.
Set oVDir = oWebAdmin.Get(_ 
"VirtualDirectory.SiteName='Default Web Site',ApplicationPath='/',Path='/'")

' Set the physical path for the default Web site.
oVDir.PhysicalPath = "C:\MyContent"
oVDir.Put_

Subclasses

This class contains no subclasses.

Inheritance Hierarchy

ConfiguredObject

   Site

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

Application Class [IIS 7 and higher]

ApplicationElementDefaults Class [IIS 7 and higher]

ApplicationPool Class [IIS 7 and higher]

BindingElement Class [IIS 7 and higher]

ConfiguredObject Class [IIS 7 and higher]

ServerContainsSite Class [IIS 7 and higher]

SiteContainsApplication Class [IIS 7 and higher]

SiteContainsConfigurationSection Class [IIS 7 and higher]

SiteElementDefaults Class [IIS 7 and higher]

SiteLimits Class [IIS 7 and higher]

SiteLogFile Class [IIS 7 and higher]

TraceFailedRequestsLogging Class [IIS 7 and higher]

VirtualDirectory Class [IIS 7 and higher]

VirtualDirectoryElementDefaults Class [IIS 7 and higher]