Using Configuration.Section to access subsection

I have a section in Web.Config:


  <applicationSettings>


    <FSBsnsCsLib.Properties.Settings>



   </</FSBsnsCsLib.Properties.Settings>


 </</applicationSettings>


I’ve tried to access inner section using shortcut “Section/Subsection“


string sSectionName=”applicationSettings/FSBusinessLib.My.MySettings”;
System.Configuration.ClientSettingsSection sectSettings = (ClientSettingsSection)config.Sections[sSectionName];


but it returned null.


The correct way is the following:


const string cnstApplicationSection = applicationSettings;
ConfigurationSectionGroup grpApplicationSection = config.SectionGroups[cnstApplicationSection];
string sSectionName=”FSBusinessLib.My.MySettings”;
System.Configuration.ClientSettingsSection sectSettings = grpApplicationSection .Sections[sSectionName];

This approach is used in my ConfigurationHelper class

Advertisements