It seems your issue is similar to the one specified on the glass mapper issue list https://github.com/mikeedwards83/Glass.Mapper/issues/163. The workaround for the error is replacing the GetViewRenderer
pipeline action:
public class GetViewRendererWithItemValidation : GetViewRenderer
{
protected override Renderer GetRenderer(Rendering rendering, GetRendererArgs args)
{
var viewRenderer = base.GetRenderer(rendering, args) as ViewRenderer;
if (viewRenderer == null)
return null;
// Ignore item check when in page editor
// Also this will break if the item for the datasource has been deleted without removing the link.
if (Context.PageMode.IsPageEditor || Context.PageMode.IsPageEditorEditing)
return viewRenderer;
// Override renderer to null when there is an unpublished item refererenced by underlying view
return viewRenderer.Rendering.Item != null && viewRenderer.Rendering.RenderingItem.InnerItem != null
? viewRenderer
: null;
}
}
Add the above as a new class in your project and activate the existing glass mapper config file z.Glass.Mapper.Sc.ViewRender.config.exclude
Also if you are using glass mapper version 4 or higher you can leave the model field blank and Glass should resolve the model based on the declaration in the view rendering's cshtml file.