Showing posts with label check appSettings tag. Show all posts
Showing posts with label check appSettings tag. Show all posts

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...