In asp.net it is easy to access key values from web.config file using configuration assembly.Here in this post I will given an example to check whether the key value is exists or not for SharePoint site.The SharePoint provides a class "webconfigurationManager" to access the key values from web.config file.Using the below bool method I will check the key value
public static bool checkkeyvalues() { using (SPSite sw = new SPSite(URL)) { System.Configuration.Configuration cfig = WebConfigurationManager.OpenWebConfiguration("/", Sw.WebApplication.Name);
AppSettingsSection aps = cfig.AppSettings;
return aps.ElementInformation.IsPresent; } }
No comments:
Post a Comment