Copied to clipboard

Flag this post as spam?

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


  • Jon 92 posts 166 karma points
    Oct 21, 2020 @ 13:43
    Jon
    0

    Umbraco 8.8 Model.url - Obsolete??

    In version 8.8 – is Model.url now obsolete?

    In the code it says it is but I don’t see any documentation online to say it’s a breaking change.

    Will we have to re-visit all our code if we upgrade?

    Thanks

    Jon

  • Nik 1611 posts 7237 karma points MVP 7x c-trib
    Oct 21, 2020 @ 14:14
    Nik
    0

    Hi Jon,

    The HQ have marked the property as Obsolete but it's still available for now. So no, currently you can upgrade and it will all continue to work.

    However, they are encouraging the use of the extension method .Url() which allows for parameters to be passed in to indicate what type of URL to render (absolute or relative). So, although not required, it's advisable to switch out .Url with .Url() at some point. I do bits when working on different sections of a site.

    I suspect that when the property is removed permanently (vNext I guess), that is when it will be flagged as breaking change.

    Does that help?

    Cheers

    Nik

  • Jon 92 posts 166 karma points
    Oct 21, 2020 @ 14:21
    Jon
    0

    Hi Nik, Thanks for this. The biggest issue we find is using it in a class. For example,

        var umbracoHelper = Umbraco.Web.Composing.Current.UmbracoHelper;
        IPublishedContent currentPage = umbracoHelper.Content(thisPage);
        var url = currentPage.Url;
    

    If we change this to Url() - it throws this error:

    Non-invocable member 'IPublishedContent.Url' cannot be used like a method.

    Have I missed something obvious :) ?

    Thanks

  • Jon 92 posts 166 karma points
    Oct 21, 2020 @ 14:24
    Jon
    1

    Hold that thought - we hadn't included Ubraco.web into the class - school boy error :)

  • Jonathon Cove 26 posts 101 karma points
    Nov 17, 2021 @ 09:09
    Jonathon Cove
    0

    Thanks for mentioning this part!

Please Sign in or register to post replies

Write your reply to:

Draft