views:

629

answers:

2

I know I have done this before but I can't seem to remember where or how.

I want to create a link to an Item in Sitecore. This code:

Sitecore.Data.Items.Item itm = Sitecore.Context.Database.GetItem(someID);
return itm.Paths.Path.ToString();

Produces the following string:

http://localhost/sitecore/content/Home/Item1/Item11/thisItem

I would like to have this string instead:

http://localhost/Item1/Item11/thisItem.aspx

What is the correct way to get the path to the item? In this case I can't use a normal Sitecore link:

Sitecore.Web.UI.WebControls.Link
+6  A: 

You're needing this one, assuming you're running Sitecore v6.

Sitecore.Links.LinkManager.GetItemUrl( item );

Mark Cassidy
+1  A: 

If you are still using Sitecore 5.3, you can use this. Be warned this method is depreciated in Sitecore 6.0.

string url = item.Paths.GetFriendlyUrl();
James Lawruk