Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Facing issue On Upgrading EPiServer 7 app to 7.5

Vote:
 

Hi,

We are upgrading an application from EPiServer 7 to 7.5 and after successfully running the Deployment Center tool we are getting a runtime exception as below:

The model item passed into the dictionary is of type 'Castle.Proxies.LatestNewsBlockProxy', but this dictionary requires a model item of type 'Project.External.Web.Models.LatestNewsBlockViewModel'.

which means instead of ViewModel Proxy is being added to the dictionary.

This is being thrown in the line marked in BOLD below:

public static MvcHtmlString ContentAreaFor(this HtmlHelper html, 
Expression> expression, object additionalViewData, bool addFullRefresh = false)
where TValue : ContentArea
{
if (PageEditing.PageIsInEditMode) {
if (addFullRefresh) {
FullRefreshProperty(html, expression);
}
return html.PropertyFor(expression, additionalViewData);
}

html.ViewContext.TempData[ContentAreaPreviewKey] = (expression.Body as MemberExpression).Member.Name;
var builder = new StringBuilder();
using (var writer = new StringWriter(builder)) {
var internalHelper = new HtmlHelper(new ViewContext(html.ViewContext.Controller.ControllerContext,
html.ViewContext.View,
html.ViewContext.ViewData,
html.ViewContext.TempData, writer), html.ViewDataContainer);

var contentAreaData = expression.Compile().Invoke(html.ViewData.Model) ?? new ContentArea();
foreach (var contentBlock in contentAreaData.FilteredContents) {
internalHelper.RenderContentData(contentBlock, false);
}
}
return new MvcHtmlString(builder.ToString());
}

Could you please help me out to fix this issue.

#143094
Jan 12, 2016 12:37
Vote:
 

Add a partial view for the latestnewsblock that accepts the block as model / transform your block to your viewmodel and render that

#143959
Feb 03, 2016 23:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.