Here is the solution to this :
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
SPWebApplication webApp = web.Site.WebApplication;
Configuration config = WebConfigurationManager.OpenWebConfiguration("/", webApp.Name);
// App settings are retrieved this way
config.AppSettings.Settings["someAppSettingKey"].Value;
// Connection string settings are retrieved this way
config.ConnectionStrings.ConnectionStrings["someDBConnectionString"].ConnectionString
web.Site.Dispose();
}
Reference :
Read web.config on FeatureActivated event while activating Feature using PowerShell
No comments:
Post a Comment