Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Adds an element to a collection in a configuration section.
Syntax
ConfigurationSectionWithCollection.Add collectionName, element;
ConfigurationSectionWithCollection.Add collectionName, element
Parameters
| 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. | 
Return Value
This method does not return a value.
Remarks
When you use the Add method, the changes you make are saved automatically. You do not need to use the Put_ method.
Example
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
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
CollectionElement Class [IIS 7 and higher]