Monday, August 17, 2009

c# programmatically check the "<appSettings>" tag in web.config file of sharepoint sites

To check programmatically weather the appSettings tag is present in the web.config file of SharePoint sites, here is the code

using (SPSite site = new SPSite("http://servername:portnumber"))
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("/", mySite.WebApplication.Name);
AppSettingsSection appSettings = config.AppSettings;
bool isAppSettingsTagPresent = appSettings.ElementInformation.IsPresent;
}

hope this helps you very much...

1 comment:

digital certificate said...

Wow! What an eye opener this post has been for me. Very much appreciated, bookmarked, I can’t wait for more!