ConfigurationSection.RevertToParent メソッド

セクションの構成値を既定値に戻します。

構文

ConfigurationSection.RevertToParent();  
ConfigurationSection.RevertToParent(PropertyName);  
ConfigurationSection.RevertToParent  
ConfigurationSection.RevertToParent(PropertyName)  

Parameters

名前 Definition
PropertyName 構成セクションのプロパティの名前を含むオプションの string 値。 このプロパティは入れ子にすることができます (例: oLogSection.RevertToParent("CentralBinaryLogFile.Directory"))。

戻り値

このメソッドは値を返しません。

解説

このメソッドは、構成ファイルに書き込まれた構成値を削除する方法を提供します。

次の例は、RevertToParent メソッドを使用する 2 つの方法を示しています。

  1. 最初の部分では、指定したプロパティを既定値に戻します。 例の次の行では、プロパティ名を RevertToParent パラメーターとして指定することで、既定の Web サイトの DefaultDocumentSectionEnabled プロパティを元に戻します。

    oDefaultDocumentSection.RevertToParent("Enabled")  
    

    これにより、既定の Web サイトの Web.config ファイルで指定された値 false が削除され、既定値 true に置き換えられます。

  2. 2 番目の部分では、セクション全体が既定値に戻されます。 例の次の行では、RevertToParent のパラメーターを指定せず、既定の Web サイトの DefaultDocumentSection のコンテンツ全体を元に戻します。

    oDefaultDocumentSection.RevertToParent  
    

    これにより、既定の Web サイトの Web.config ファイルの既定のドキュメント セクションからのすべての値が削除されます。 削除された値は、既定の Web サイトの既定値に置き換えられます。

' 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  
  

要件

説明
クライアント - Windows Vista 上の IIS 7.0
- Windows 7 上の IIS 7.5
- Windows 8 上の IIS 8.0
- Windows 10 上の IIS 10.0
[サーバー] - Windows Server 2008 上の IIS 7.0
- Windows Server 2008 R2 上の IIS 7.5
- Windows Server 2012 上の IIS 8.0
- Windows Server 2012 R2 上の IIS 8.5
- Windows Server 2016 上の IIS 10.0
Product - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF ファイル WebAdministration.mof

参照

ConfigurationSection クラス
ConfigurationSectionWithCollection クラス
ConfiguredObject クラス
DefaultDocumentSection クラス