配置文件分组,获得权限访问页面

<configuration>
  <configSections>
    <sectionGroup name="TestGroup">
      <section  name="admin"  type="System.Configuration.NameValueSectionHandler"></section>
      <section  name="customer"  type="System.Configuration.NameValueSectionHandler"></section>
      <section  name="test3"  type="System.Configuration.NameValueSectionHandler"></section>
    </sectionGroup>
  </configSections>
  <TestGroup>
    <admin>
      <add key="1" value="Main"></add>
      <add key="2" value="Coupon"></add>
      <add key="3" value="Tuan"></add>
      <add key="4" value="Product"></add>
      <add key="5" value="ProdPromotion"></add>
      <add key="6" value="PromotionList"></add>
      <add key="7" value="UpdatePwd"></add>
      <add key="8" value="UserCmsList"></add>
      <add key="9" value="CmsList"></add>
    </admin>
    <customer>
      <add key="1" value="Main"></add>
      <add key="2" value="Product"></add>
      <add key="3" value="ProdPromotion"></add>
      <add key="4" value="PromotionList"></add>
      
    </customer>
    <test3>
      <add key="user3" value="3"></add>
    </test3>
  </TestGroup>

 读取的时候

            NameValueCollection nc = (NameValueCollection)ConfigurationSettings.GetConfig("TestGroup/admin");
            foreach (var key in nc.AllKeys)
            {
             value= nc[key].ToString() 
            }

 ConfigurationSettings.GetConfig("TestGroup/admin");//这个节点是大组下面的子类admin,

原文地址:https://www.cnblogs.com/gylspx/p/ssss.html