配置节要指定处理程序的
就你的情况,直接用
<appSettings>
<add key="RootURL" value="http://localhost/MySite/" />
<add key="ConnectionString" value="" />
<add key="Duwamish.Web.EnableSsl" value="False" />
</appSettings>或
<configuration>
<configSections>
<section name="MyConfiguration" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<appSettings>
<add key="RootURL" value="http://localhost/MySite/" />
</appSettings>
        <MyConfiguration>
<add key="ConnectionString" value="" />
<add key="Duwamish.Web.EnableSsl" value="False" />
</MyConfiguration>
</configuration>才行,不过用法一致

解决方案 »

  1.   

    实现 IConfigurationSectionHandler 接口
    下面的示例定义 IConfigurationSectionHandler 接口。[C#]
    namespace System.Web.Configuration 
    {
       public interface IConfigurationSectionHandler 
       {
          public Object Create(Object parent, Object input, 
             XmlNode node);
       }
    }
    您还可以定义自己的节,该节与 <appSettings> 节使用相同的配置处理程序。例如:
    <configuration>
       <configSections>
          <sectionGroup name="myGroup">
             <sectionGroup name="nestedGroup">
                <section name="mySection" type=
                   "System.Configuration.NameValueSectionHandler,System"/>
             </sectionGroup>
          </sectionGroup>
       </configSections>   <myGroup>
          <nestedGroup>
             <mySection>
                <add key="key_one" value="1"/>
                <add key="key_two" value="2"/>
             </mySection>
          </nestedGroup>
       </myGroup>
    </configuration>
    您可以读取上面的示例中定义的新配置节的值,如下:NameValueCollection config = (NameValueCollection)
       ConfigurationSettings.GetConfig("myGroup/nestedGroup/mySection");
    Response.Write("The value of key_one is " + config["key_one"] + "<br>");
    Response.Write("The value of key_two is " + config["key_two"] + "<br>");