views:

24

answers:

1

This is part of my web.config

<location path="Secure">
    <system.web>
      <authorization>
        <allow users="SecureUsers" />
      </authorization>
    </system.web>
  </location>

I want to be able to search for path of Secure and find out the user role that is specified.

My input is the path, such as "Secure" and the value I'm trying to retrieve is "SecureUsers".

A: 

I think you want to open the config and cast it as a Configuration object before you can really get what you want. You might also be able to read the config file using LINQ to XML too, but here is how you would do it otherwise.

Configuration config = ConfigurationManager.OpenExeConfiguration(Server.MapPath("~/web.config"));
    ConfigurationLocationCollection myLocationCollection = config.Locations;

    foreach (ConfigurationLocation myLocation in myLocationCollection)
    {
        if (myLocation.Path == "Secure")
        {

        }
    }
Banzor