We upgrade to web 8 and upgraded an existing .NET DD4T 1.31 website to .NET DD4T 2.0. We have made necessary changes to compile the Website with latest DD4T 2.0 DLL and web 8 DLLs and JAR files successfully. While Most of the websites works few of the Page templates which uses RenderComponentPresentationsByView is giving empty result.
When verified using Tridion Delivery API we are getting correct output.
When checked in the below post, it is mentioned to use @Html.Render(cp) while using DD4T View Models.
DD4T good practice: how to render component presentations based on ViewModels
We are using DD4T View Models, but Since it will take long time to change the code, can you please suggest how can we make RenderComponentPresentationsByView works in DD4T 2.0
Other issue we are facing to call render(cp) function is when we use below syntax we are getting null exception while trying to check component template metadata.
@foreach (var cp in Model.ComponentPresentations)
{
if (CP.ComponentTemplate.MetadataFields["view"].Value =="GenericBannerImage")
{
@Html.Render(cp)
}
}
Any help would be appreciated.
Syntax used :
@Html.RenderComponentPresentationsByView("GenericBannerImage")