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:
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.
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.
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.
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).
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:
The object then looks like this: icon2.DataValue = "umb://media/d594517b078a45248a9cb1479d4cb1a5"
Executing
Model.Content.GetPropertyValue("icon2")
throws the following error:Model.Content.GetPropertyValue<IPublishedContent>("icon2")
throws the same error.What am I doing wrong?
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.
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.
In your web.config there should be a line about core property value converters. Is that switched on or off?
It's switched on.
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).
is working on a reply...