In a DD4T View I am trying to pick the value of Path of the keyword inside the Category.
foreach(var category in @Model.Categories)
{
if (category.Title.Contains("Taxonomy"))
{
str = category.Keywords[0].Path;
break;
}
}
but getting null in @Model.Categories.
Error: Object reference not set to instance of the object.
Although data exist in XML.
Please suggest.
I discovered this is an issue in DD4T. The work-around is quite simple: if you use the implementation of Component (or Page) as your model, rather than the interface, it works.
So start your view with:
Rather than
And try again.