The following example defines an IConfigurationSectionHandler interface.
[Visual Basic] Namespace System.Web.Configuration Public Interface IConfigurationSectionHandler Function Create(parent As Object, input As Object, _ node As XmlNode) As Object End Interface End Namespace [C#] namespace System.Web.Configuration { public interface IConfigurationSectionHandler { public Object Create(Object parent, Object input, XmlNode node); } }
You can also define your own section that uses the same configuration handler as the <appSettings> section. For example:
<configuration>
<configSections>
<sectionGroup name="myGroup">
<sectionGroup name="nestedGroup">
<section name="mySection"
type="System.Configuration.NameValueSectionHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=9b35aa32c18d4fb1 />
</sectionGroup>
</configSections>
<myGroup>
<nestedGroup>
<mySection>
<add key="key_one" value="1" />
<add key="key_two" value="2" />
</mySection>
</nestedGroup>
</myGroup>
</configuration>
You can read the value of the new configuration section defined in the preceding example as follows:
[Visual Basic] Dim config As 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>") [C#] 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>");