UrlAction Tokens in SharePoint 2010

When creating CustomAction Elements, a number of tokens are available for use within the UrlAction Element in SharePoint 2010. The list of UrlAction tokens in SharePoint 2010 has grown ever so slightly (For a SharePoint 2007 reference, see UrlAction Tokens Of The CustomAction Feature).

Tokens

Key
Available in 2007
Available in 2010
Token Replacement
~site/ SPContext.Current.Web.ServerRelativeUrl
~sitecollection/ SPContext.Current.Site.ServerRelativeUrl
{ItemId} SPListItem.ID.ToString() or SPListItem["BdcIdentity"] (external data source)
{ItemUrl} SPListItem.Url
{SiteUrl} SPWeb.Url
{ListId} SPList.ID.ToString(“B”)
{RecurrenceId} SPListItem.RecurrenceID
{ListUrlDir} SPList.RootFolder.Url
{Source} Current Request Url

Microsoft.SharePoint.SPCustomActionElement.ReplaceUrlTokens

internal static string ReplaceUrlTokens(string urlAction, SPWeb web, SPList list, SPListItem item)
{
	if (string.IsNullOrEmpty(urlAction))
	{
		return urlAction;
	}
	if (item != null)
	{
		int d = item.ID;
		string str1 = d.ToString(CultureInfo.InvariantCulture);
		if (list.HasExternalDataSource)
		{
			str1 = item["BdcIdentity"] as string;
		}
		urlAction = urlAction.Replace("{ItemId}", str1);
		urlAction = urlAction.Replace("{ItemUrl}", item.Url);
		string recurrenceID = str1;
		if (!string.IsNullOrEmpty(item.RecurrenceID))
		{
			recurrenceID = item.RecurrenceID;
		}
		urlAction = urlAction.Replace("{RecurrenceId}", recurrenceID);
	}
	if (web != null)
	{
		urlAction = urlAction.Replace("{SiteUrl}", web.Url);
	}
	if (list != null)
	{
		urlAction = "{ListId}".Replace(Guid guid = list.ID, guid.ToString("B"));
		if (list.RootFolder != null)
		{
			urlAction = urlAction.Replace("{ListUrlDir}", list.RootFolder.Url);
		}
	}
	HttpContext current = HttpContext.Current;
	if (current != null && current.Request != null)
	{
		string rawUrl = current.Request.RawUrl;
		Uri contextUri = SPAlternateUrl.ContextUri;
		if (!string.IsNullOrEmpty(rawUrl) && null != contextUri)
		{
			string str2 = null;
			if (!SPUtility.StsStartsWith(rawUrl, "/"))
			{
				str2 = string.Concat(contextUri.GetLeftPart(UriPartial.Authority), "/", rawUrl);
			}
			else
			{
				str2 = string.Concat(contextUri.GetLeftPart(UriPartial.Authority), rawUrl);
			}
			urlAction = urlAction.Replace("{Source}", SPHttpUtility.UrlKeyValueEncode(str2));
		}
	}
	urlAction = SPUtility.GetServerRelativeUrlFromPrefixedUrl(urlAction);
	return urlAction;
}

Reference

Updated Guidance: Developing Applications for SharePoint 2010

Microsoft just released an updated version of it’s guidance for Developing Applications for SharePoint 2010.

From Microsoft:

Developing Applications for SharePoint 2010 contains guidance documentation, detailed examples, and a reusable class library. These resources are designed to help solution developers and architects make the right decisions and follow proven practices when designing and developing applications for Microsoft® SharePoint® 2010. The guidance focuses on the building blocks that every developer needs to understand to become an effective SharePoint developer or architect.The guide is provided as a Help (.chm) file and has four core areas: application foundations, execution models, data models, and client models. Eight reference implementations illustrate the core concepts covered in the guide. The reusable class library provides code to help developers build more manageable, flexible, and testable applications. Source code is provided for all reference implementations and for the reusable library. The reference implementations have automated setup scripts to configure the applications.

Reference

Some Background on CAS Policies

Reza Alirezaei has a good post on the behind the scenes of CAS policies and SharePoint.

Check it out.

Performance Optimization WordPress Plugins by W3 EDGE