web.config中有一些自定义keyvalue配置节,想要在线修改,找了半天没找到现成的,自己写了一个:

就是类似这样的配置节:
在线修改KeyValue配置节    <system.framework>        
在线修改KeyValue配置节        
<add key="SystemFramework.Tracing.Enabled" value="True" />
在线修改KeyValue配置节        
<add key="SystemFramework.Tracing.TraceLevel" value="4" />
在线修改KeyValue配置节    
</system.framework>

写了4个类:
配置项:NameValueConfigurationItem
    }

配置项集合:NameValueConfigurationCollection
    }

配置节处理类:NameValueConfigurationSection
    }

具体配置节处理类:FrameworkConfiguration
    }

配置节处理配置:
在线修改KeyValue配置节<configSections>
在线修改KeyValue配置节    
<section name="system.framework" type="Framework.Configuration.FrameworkConfiguration, Framework" />
在线修改KeyValue配置节
</configSections>

修改配置:
在线修改KeyValue配置节System.Configuration.Configuration config
                = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");

            Mars.Utility.Web.Configuration.NameValueConfigurationSection
                section =
                (Mars.Utility.Web.Configuration.NameValueConfigurationSection)
            config.GetSection("system.framework");

            section.Settings.Remove(_key);
            section.Settings.Add(new Mars.Utility.Web.Configuration.NameValueConfigurationItem(_key,TextBoxValue.Text));

            config.Save(ConfigurationSaveMode.Modified);


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-23
  • 2022-01-05
  • 2021-09-17
  • 2021-07-13
  • 2021-08-11
  • 2022-12-23
相关资源
相似解决方案