ConfigurationSectionWithCollection.Add Method
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 | - IIS 7.0 on Windows Vista - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
Server | - IIS 7.0 on Windows Server 2008 - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 |
MOF file | WebAdministration.mof |
See Also
CollectionElement Class
ConfigurationSectionWithCollection Class
MimeMapElement Class