当你有一个格式不正确的web.config,并尝试编辑它在GUI中的一部分,它会popup一个框,说出来,并告诉你它打破的路线。
有没有办法访问这个function认为cmd / powershell?
你可以使用这样的代码:
$site = "Default Web Site" try { Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location "$site" -filter "system.webServer" -name . | Out-Null Write-Output "All is Well" } catch [System.Exception] { Write-Output $_ }
输出可能包括:
Get-WebConfigurationProperty : Filename: \\?\C:\inetpub\wwwroot\web.config Line number: 7 Error: Configuration file is not well-formed XML
要么
Get-WebConfigurationProperty : Filename: \\?\C:\inetpub\wwwroot\web.config Line number: 5 Error: The configuration section 'foo' cannot be read because it is missing a section declaration