Error reading content properties in RenderMvcController
I have a problem accessing the content properties in a RenderMvcController. I have a page with some children and I want to access a certain property of each child page. The problem is that the property value of the first child seems to be propagated to the siblings. Each child page has a different image but the value I read in productPage.Image is always the same. In addition, if I inspect the value of a specific child image when debugging in Visual Studio, productPage.Image is set to the value of the first inspected child! Do you know why does this happen?
public class ProductPageController : Umbraco.Web.Mvc.RenderMvcController
{
public override ActionResult Index(ContentModel model)
{
var children = contentModel.Content.Children;
foreach (var child in children)
{
if (child is ProductPage productPage)
{
// Access the product image
var image = productPage.Image;
// Do some operations, etc...
}
}
}
}
Error reading content properties in RenderMvcController
I have a problem accessing the content properties in a
RenderMvcController
. I have a page with some children and I want to access a certain property of each child page. The problem is that the property value of the first child seems to be propagated to the siblings. Each child page has a different image but the value I read inproductPage.Image
is always the same. In addition, if I inspect the value of a specific child image when debugging in Visual Studio,productPage.Image
is set to the value of the first inspected child! Do you know why does this happen?is working on a reply...