Archive for April, 2011

My latest mission has been to create a site definition in SharePoint 2010 which activates the same feature a team site but sets default.aspx as the home page like it used to do in MOSS. However, in 2010, if you copy the team site definition, the home page is set to SitePages/Home.aspx 

After some mulling around the web I eventually found out that the culprit was the new Wiki Feature. If you remove this from the site definition the site will default to detault.aspx

I also found a couple of blogs, which I’ve referenced below, which contain some excellent references for navigation in ONET.XML

 SharePoint 2007 and SharePoint 2010 Tips & tricks 

Controlling navigation options from the onet.xml

Hope this helps someone Winking smile

Well, this was not as straight-forward as i first thought. Why? Because the timer job does not run in the same App Domain as the web application. They are in two separate processes : W3WP.EXE  and OWSTIMER.EXE for the Web Application worker process and the SharePoint timer respectively.

So, how do you go about it?

Well, firstly you need to add reference to your timer job as follows (unless your using VB !):

using System.Configuration;
using System.Web.Configuration;

Reading AppSettings in Timer
  1. using (SPSite site = new SPSite("http://SiteCollectionUrl"))
  2.         {
  3.             Configuration config = WebConfigurationManager.OpenWebConfiguration("/", site.WebApplication.Name);
  4.             return config.AppSettings.Settings["AppSettingKeyToRead"].Value;
  5.         }

Admittedly, this solution is hard coding the Uri of the Site Collection, but this is purely for demonstration purposes. This can be overcome by writing to a property as described in my previous posting Custom SharePoint Job Properties

Happy coding Winking smile