zoukankan      html  css  js  c++  java
  • 在web.config 的config

    在web.config中增加一个设置

    1. 在<configSections></configSections>之间构造一个Section,如
       <configSections>
          <section name="mySection" type="System.Configuration.NameValueSectionHandler,System"/>
       </configSections>

       也可以设置成一个Section组,并且组是可以嵌套的。

       <configSections>
     <sectionGroup name="myGroup">
      <sectionGroup name="nestedGroup">
        <section name="mySection" type="System.Configuration.NameValueSectionHandler,System"/>
      </sectionGroup>
      </sectionGroup>
       </configSections>


    2. 在<configuration></configuration>之间增加Sections设置,与<configSections></configSections>平级
       <mySection>
     <add key="key_one" value="1"/>
     <add key="key_two" value="2"/>
       </mySection>

       或者用Section组方式

       <myGroup>
          <nestedGroup>
             <mySection>
                <add key="key_one" value="1"/>
                <add key="key_two" value="2"/>
             </mySection>
          </nestedGroup>
       </myGroup>

    3. 读取值

    Dim config As NameValueCollection = ConfigurationSettings.GetConfig("mySection")
    或者
    Dim config As NameValueCollection = ConfigurationSettings.GetConfig("myGroup/nestedGroup/mySection")

    用上面的方法,是在要增加的配置类型比较复杂时使用,比如上面的type就是一个类。以上的每个key都是类中的一个属性。
    如果要增加的配置只是文本字符串,还可以直接用<appSetting>配置段
    <appSettings>
      <add key="aaa" value="bbb"/>
    </appSetting>

    使用时,直接用
    dim x as string = ConfigurationSettings.appSettings("aaa")
    即可

    <location></location>配置段的用法
    <location></location>用于将一套配置应用到特定的应用程序目录
    比如,
    <system.web>
        <compilation defaultLanguage="vb"/>
    </system.web>

    <location path="C#code">
      <system.web>
         <compilation defaultLanguage="cs"/>
      </system.web>
    </location>
    中,只有在C#code目录中,默认语言是C#,其它目录中都是VB

  • 相关阅读:
    UIWebView长按弹出菜单显示英文解决办法
    远程推送不能获取token的原因(证书配置正确)
    汉字转拼音 汉字排序功能
    旋转360度动画
    获取wifi列表
    openssl生成私钥公钥的步骤
    JAVA后台框架优化之日志篇
    react native学习资料
    RAP, 高效前后端联调框架,接口文档管理工具
    【JMeter】JMeter在linux下运行
  • 原文地址:https://www.cnblogs.com/xiaotaoliang/p/123746.html
Copyright © 2011-2022 走看看