I have a custom configuration section in my web.config as follows:
<configSection> <section name="CustomConfig" type="ConfigSectionRoot" allowLocation="true" allowDefinition="Everywhere"/> </configSection> <CustomConfig> <ConfigRoot> <add key="DataBase" value="CouchDB"/> <add key="FrontEnd" value="Asp.Net"/> <add key="AppName" value="Virtual WorkPlace"/> </ConfigRoot> </CustomConfig> <AppSettings> <add key="DataBase" value="CouchDB"/> </AppSettings>
My ConfigSectionRoot.cs looks like this:
public class ConfigSectionRoot:ConfigurationSection { [ConfigurationProperty("key", DefaultValue = "", IsKey = true, IsRequired = true)] public string Key { get { return ((string)(base["key"])); } set { base["key"] = value; } } [ConfigurationProperty("value", DefaultValue = "", IsKey = false, IsRequired = false)] public string Value { get { return ((string)(base["value"])); } set { base["value"] = value; } } }
If I use AppSettings instead of Custom Config, I could access it, for example:
string results= ConfigurationManager.AppSettings["Database"];
Is there a way to achieve the same in the Customized Config section ??? Pls help me
source share