Short question this time for a change...
Is there a way to iterate through the "location" elements in a web.config?
<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>
... and say have an output of something like:
<table>
<tr>
<td>some/path</td>
<td>authorization: *</td>
</tr>
<tr>
<td>some/other/path</td>
<td>authorization: ?</td>
</tr>
</table>
Cheers :)
By using the ConfigurationLocation class .
You can retrieve your web.config like this:
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/web.config");
From there you can iterate through your locations:
foreach (ConfigurationLocation location in config.Locations)
{
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.