Site.RevertToParent Method1
将网站配置值还原为默认值。
语法
Site.RevertToParent(PropertyName)
Site.RevertToParent(PropertyName);
参数设置
名称 | 描述 |
---|---|
PropertyName |
一个可选的 string 值,其中包含要还原为 SiteElementDefaults 指定的默认值的网站属性名称。 该属性可以嵌套(例如“LogFile.Directory”)。 |
返回值
此方法不返回值。
注解
在没有参数的情况下调用 RevertToParent
时,将删除网站的所有自定义配置值。 如果这不是你想要的行为,请通过使用对该方法的参数化调用来还原特定属性。
示例
以下示例将默认网站的日志文件目录从 %SystemDrive%\MySiteLogFiles 还原到 %SystemDrive%\inetpub\logs\LogFiles。 该示例在 ApplicationHost.config 文件的针对默认网站的 <logFile>
节中进行了此更改。
注意
Site 类的 LogFile
属性包含 SiteLogFile 类的实例。 SiteLogFile
实例具有 Directory
属性。 使用 oSite.RevertToParent("LogFile.Directory")
指定此嵌套属性。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject( _
"winmgmts:root\WebAdministration")
' Retrieve the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
' Display the Web site name, ID, and log file directory.
WScript.Echo "Web site name: " & oSite.Name
WScript.Echo "Site ID: " & oSite.ID
WScript.Echo "Log file directory before revert: " & _
oSite.LogFile.Directory
' Revert the log file directory to the default.
oSite.RevertToParent("LogFile.Directory")
' Update the contents of the oSite object variable.
oSite.Refresh_
' Display the change.
WScript.Echo _
"Log file directory after revert: " & _
oSite.LogFile.Directory
' Example output:
' Web site name: Default Web Site
' Site ID: 1
' Log file directory before revert: %SystemDrive%\MySiteLogFiles
' Log file directory after revert: %SystemDrive%\inetpub\logs\LogFiles
要求
类型 | 描述 |
---|---|
客户端 | - IIS 7.0(在 Windows Vista 上) - IIS 7.5(在 Windows 7 上) - IIS 8.0(在 Windows 8 上) - IIS 10.0(在 Windows 10 上) |
服务器 | - IIS 7.0(在 Windows Server 2008 上) - IIS 7.5(在 Windows Server 2008 R2 上) - IIS 8.0(在 Windows Server 2012 上) - IIS 8.5(在 Windows Server 2012 R2 上) - IIS 10.0(在 Windows Server 2016 上) |
产品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
MOF 文件 | WebAdministration.mof |