Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Quick question; in application code, what is the current best practice for getting a URL from a node ID, e.g. as returned from Examine?
Is it still umbraco.library.NiceUrl()?
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
var node = umbracoHelper.TypedContent(nodeId);
if(node != null)
not sure if there's a faster way
You are right, this is the way:
var content= UmbracoContext.Current.ContentCache.GetById(nodeId);
Theres a NiceUrl() and NiceUrlWithDomain() method on the UmbracoHelper. I would use that.
You can learn more about the UmbracoHelper here:
I would not use umbraco.library.NiceUrl because it's a legacy API. If i'm correct it will deprecated in V8
In c# code you can use :
In your views you can use :
Perfect answer - C# plus Razor examples, exactly what I was after. Thanks Dave.
Just as a correction to this, in your views it's not @(Umbraco.Url(id)) it's actually @(UmbracoContext.Url(id)) (Quite possible this changed since original posting)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted