ConfigurationSection.RevertToParent Method [IIS 7 and higher]
Reverts configuration values in a section to their defaults.
Syntax
ConfigurationSection.RevertToParent();
ConfigurationSection.RevertToParent(PropertyName);
ConfigurationSection.RevertToParent
ConfigurationSection.RevertToParent(PropertyName)
Parameters
Name |
Definition |
---|---|
PropertyName |
An optional string value that contains the name of a property in the configuration section. The property can be nested (for example, oLogSection.RevertToParent("CentralBinaryLogFile.Directory"). |
Return Value
This method does not return a value.
Remarks
This method provides a way to delete configuration values that have been written to a configuration file.
Example
The following example shows two ways of using the RevertToParent method:
The first part reverts a specified property to the default value. The following line from the example reverts the Enabled property of DefaultDocumentSection of the default Web site by specifying the property name as a RevertToParent parameter.
oDefaultDocumentSection.RevertToParent("Enabled")
This removes the value of false, which was specified in the Web.config file of the default Web site, and replaces it with the default value of true.
The second part reverts an entire section to the default values. The following line from the example reverts the entire DefaultDocumentSection contents of the default Web site by specifying no parameters for RevertToParent.
oDefaultDocumentSection.RevertToParent
This removes all values from the default document section in the Web.config file of the default Web site. The default values of the default Web site replace the removed values.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Get the DefaultDocumentSection for the Default Web Site.
Set oSite=oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "DefaultDocumentSection", oDefaultDocumentSection
' 1. Revert the Enabled property to its default value.
oDefaultDocumentSection.RevertToParent("Enabled")
' 2. Revert the entire default document section.
oDefaultDocumentSection.RevertToParent
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
ConfigurationSection Class [IIS 7 and higher]
ConfigurationSectionWithCollection Class [IIS 7 and higher]