SiteCollection.Add Method (String, String, String, String)

IIS 7.0
 

Creates a new site by using the specified parameters and adds it to the site collection.

Namespace:   Microsoft.Web.Administration
Assembly:  Microsoft.Web.Administration (in Microsoft.Web.Administration.dll)

public Site Add(
	string name,
	string bindingProtocol,
	string bindingInformation,
	string physicalPath
)

Parameters

name
Type: System.String

The name to assign to the site (for example, "Default Web Site").

bindingProtocol
Type: System.String

A comma-delimited list of protocols that the new site should use.

bindingInformation
Type: System.String

A colon-delimited set of data that indicates the IP address, port, and host headers that the site listener should be bound to.

physicalPath
Type: System.String

The physical location of the content that this site will provide access to.

Return Value

Type: Microsoft.Web.Administration.Site

A reference to the newly created Site object.

Exception Condition
FormatException

The name parameter that is passed to the method is null or is a zero-length string.

This method creates a Site object and adds it to the SiteCollection object in memory. However, to commit the site configuration to the configuration system, you will need to use the ServerManager class to perform an update. The instance returned from this call does not reflect the default site values specified in the SiteDefaults property of the ServerManager object.

The following example creates a site and updates the configuration system.

Return to top
Show: