这次简短的问题需要改变......
有没有办法遍历web.config中的“location”元素?
<configuration>
...
<location path="some/path">
<system.web>
<authorization users="*" />
</system.web>
</location>
<location path="some/other/path">
<system.web>
<authorization users="?" />
</system.web>
</location>
...
<configuration>
...并且说输出类似于:
<table>
<tr>
<td>some/path</td>
<td>authorization: *</td>
</tr>
<tr>
<td>some/other/path</td>
<td>authorization: ?</td>
</tr>
</table>
干杯:)
答案 0 :(得分:3)
按using the ConfigurationLocation class。
您可以像这样检索您的web.config:
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/web.config");
从那里你可以遍历你的位置:
foreach (ConfigurationLocation location in config.Locations)
{
}