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()); }
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, object additionalViewData, bool addFullRefresh = false)
Expression
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.