I think that Umbraco.NiceUrl(id) is the same as Umbraco.Content(id).Url, performance wise but I think is to make the option available for people who used XSLT back in the days where the extension method to get a nice url was called NiceUrl, so they are familiar with this name, but the Umbraco.Content(id).Url would also give you a nice url.
If other people in this community have something to add or I am wrong then please add.
Just to add one point that Umbraco.Content is correct to use in the front-end as it uses the cache and not the database. It's only when you use ContentService that you are going back to the database.
retrieving url by id and its performance
Hi guys,
I've noticed that there's many ways of retrieving url in Umbraco.
e.g.
I'm assuming that library.NiceUrl(id) is old way of doing and got replace by Umbraco helper class? which is Umbraco.NiceUrl(id)??
How about the Umbraco.Content(id).Url? I'm assuming this cost more cause it needs to retrieve data from database? and retrieve all the fields?
where the Umbraco.NiceUrl retrieves only url so its faster?
I'm just trying to understand whats the best of retrieving data
Thank you
Shinsuke
Hi Shinsuke,
The Library.NiceUrl(id), is the library methods if you are using the old DynamicNode razor, which you shouldn't, this Razor version is deprecated.
The Umbraco.Content(id).Url this the new way to call UmbracoHelpers in MVC http://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/
I think that Umbraco.NiceUrl(id) is the same as Umbraco.Content(id).Url, performance wise but I think is to make the option available for people who used XSLT back in the days where the extension method to get a nice url was called NiceUrl, so they are familiar with this name, but the Umbraco.Content(id).Url would also give you a nice url.
If other people in this community have something to add or I am wrong then please add.
Hope this helps,
/Dennis
Just to add one point that Umbraco.Content is correct to use in the front-end as it uses the cache and not the database. It's only when you use ContentService that you are going back to the database.
Andy
is working on a reply...