Creating Custom Configuration Sections
-
I am trying to implement custom configuration sections in the web.config. I have included the following custom config setting in my web.config :
I am now trying to retrieve the custom config values in my .cs codebhind file using the following code : System.Collections.Specialized.NameValueCollection nvc = (System.Collections.Specialized.NameValueCollection) System.Configuration.ConfigurationSettings.GetConfig("sitesettings/common/emails"); Label1.Text = nvc["salesmail"]; When I do this , I am getting the following exception : ex.Message : Exception creating section handler. (c:\inetpub\wwwroot\CustomConfig\web.config line 6) ex.Source : System.Web ex.StackTrace : at System.Web.Configuration.HttpConfigurationRecord.GetFactory(String configKey) at System.Web.Configuration.HttpConfigurationRecord.Evaluate(String configKey, SectionRecord section) at System.Web.Configuration.HttpConfigurationRecord.GetConfig(String configKey, Boolean cacheResult) at System.Web.Configuration.HttpConfigurationRecord.GetConfig(String configKey, Boolean cacheResult) at System.Web.HttpContext.GetConfig(String name) at System.Web.Configuration.HttpConfigurationSystemBase.System.Configuration.IConfigurationSystem.GetConfig(String configKey) at System.Configuration.ConfigurationSettings.GetConfig(String sectionName) at CustomConfig.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\customconfig\webform1.aspx.cs:line 53 Label Does anyone know what is wrong with my code? Thanks Sujatha