Make your Sharepoint Job read values from web.config

16 April 2009 5:29 AM Posted by Mano Mangaldas

// get the settings
System.Configuration.Configuration myConfig;
//myConfig = WebConfigurationManager.OpenWebConfiguration("/", "C1st_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);
}

//Construct the complete URL
SITECOLLECTION_URL = WebApplication.GetResponseUri(SPUrlZone.Default).ToString() + SITECOLLECTION_URL;

Comments (0)

Post a Comment