How to read the correct web.config setting
01 April 2010
8:20 AM
Posted by
Mano Mangaldas
Suppose you have created a job and scoped to multiple web application.. the job should be smart enough to pick up the correct setting you may have added in the config file.. below is the code to get it..
// get the settings
System.Configuration.Configuration myConfig;
//myConfig = WebConfigurationManager.OpenWebConfiguration("/", "SharePoint_500");
myConfig = WebConfigurationManager.OpenWebConfiguration("/", this.WebApplication.Name);
if (!myConfig.Equals(null))
{
this.connStrFromAppSettings = myConfig.AppSettings.Settings["ConnectionString"].Value;
this.CUSTOM_SITE_TEMPLATE_NAME = myConfig.AppSettings.Settings["CustomSiteTemplateName"].Value;
this.SITECOLLECTION_URL = myConfig.AppSettings.Settings["SiteCollectionURL"].Value;
this.BUFFER_SIZE = Convert.ToInt32(myConfig.AppSettings.Settings["BufferSize"].Value);
}
Comments (0)
Post a Comment