Copied to clipboard

Flag this post as spam?

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


  • Costin 4 posts 74 karma points
    Aug 01, 2017 @ 15:00
    Costin
    0

    Can't get media image URL from Umbraco after upgrade

    I have recently upgraded to 7.6.3 and I am having an issue retrieving media image URLs in my views. For testing purpposes, I added a new MediaPicker2 property for one of the nodes, set up a value for it and tried to get its value in my razor view:

    var icon2 = Model.Content.GetProperty("icon2");
    

    The object then looks like this: enter image description here icon2.DataValue = "umb://media/d594517b078a45248a9cb1479d4cb1a5"

    Executing Model.Content.GetPropertyValue("icon2") throws the following error:

    An exception of type 'System.Exception' occurred in Umbraco.Core.dll but was not handled in user code

    Additional information: Exception while creating a value.

    InnerException: "Object reference not set to an instance of an object."

    Model.Content.GetPropertyValue<IPublishedContent>("icon2") throws the same error.

    What am I doing wrong?

  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 01, 2017 @ 18:09
    Sven Geusens
    0

    If its a normal picker that has the pick multiple option enabled (or a multi treenode picker) then try Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("icon2")

    Also, are you sure that line is throwing the error. Razorscript can be fickle sometimes. Add a var temp = 1; right behind your getpropvalue statement and put a breakpoint on the new line.

    The data value of the property is correct, its the new kind of id umbraco is using to get rif of all the int ids.

  • Costin 4 posts 74 karma points
    Aug 02, 2017 @ 08:42
    Costin
    0

    That's the line that throws the error alright. I have a bunch more code lines there and I've placed a breakpoint. When I try to go over that line in my code it throws the error.

  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 02, 2017 @ 08:48
    Sven Geusens
    0

    In your web.config there should be a line about core property value converters. Is that switched on or off?

  • Costin 4 posts 74 karma points
    Aug 02, 2017 @ 08:48
    Costin
    0

    It's switched on.

  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 02, 2017 @ 09:24
    Sven Geusens
    0

    Alright last idea, It seems like you already used the core property value converter before you upgraded to 7.6. Is that nuget/umbracopackage/dll still present somewhere? If so, delete it, it might be causing issues with the one that has been integrated in the core. The old standalone does not know how to work with new types of id (as far as i know).

Please Sign in or register to post replies

Write your reply to:

Draft