Export (0) Print
Expand All
Expand Minimize

ConfigurationSectionWithCollection.Add Method [IIS 7 and higher]

IIS 7.0

Adds an element to a collection in a configuration section.

ConfigurationSectionWithCollection.Add collectionName, element;
ConfigurationSectionWithCollection.Add collectionName, element

Name

Definition

collectionName

A string value that contains the name of the collection that will be added to.

element

A CollectionElement object to which the element will be added.

This method does not return a value.

When you use the Add method, the changes you make are saved automatically. You do not need to use the Put_ method.

The following example adds a MIME map to the default Web site.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

' Get the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")

' Get the static content section by using the GetSection method.
oSite.GetSection "StaticContentSection", oStaticContentSection

' Get the MimeMapElement class object.
Set oMimeMapElement = oWebAdmin.Get("MimeMapElement")

' Spawn a new instance of the MimeMapElement class.
Set oNewMimeMap = oMimeMapElement.SpawnInstance_

' Assign values to the FileExtension and MimeType properties.
oNewMimeMap.FileExtension = "MyFileExtension"
oNewMimeMap.MimeType = "application/MyApp"

' Add the MIME map to the collection.
oStaticContentSection.Add "StaticContent", oNewMimeMap

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

Community Additions

ADD
Show:
© 2015 Microsoft