Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • shinsuke nakayama 109 posts 250 karma points
    Nov 03, 2014 @ 10:44
    shinsuke nakayama
    0

    retrieving url by id and its performance

    Hi guys,

    I've noticed that there's many ways of retrieving url in Umbraco.

    e.g.

    Umbraco.NiceUrl(id);
    library.NiceUrl(id)
    Umbraco.Content(id).Url
    

    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

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 03, 2014 @ 11:07
    Dennis Aaen
    0

    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

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Nov 04, 2014 @ 22:37
    Andy Butland
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft