We recently upgraded our Sitecore to 9.1
and also Glassmapper5.4.21
along with it.
What we noticed is that some of the view renderings have a data source that does not have a version in a particular language.
While it worked in the older version, in the new version this throws an exception as below. the only workaround we found is to go and create versions for those items. (even though we did not need them in that language) .
> The model item passed into the dictionary is of type > 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary > requires a model item of type 'MyProject.IHeaderAndCopy'. Description: > An unhandled exception occurred. > > Exception Details: System.InvalidOperationException: The model item > passed into the dictionary is of type > 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary > requires a model item of type 'MyNamespace.Models.IHeaderAndCopy'.
my View rendering code
@model IHeaderAndCopy
@if (Model != null)
{
<h2>@Html.Glass().Editable(x => x.Header)</h2>
}
Any idea how to fix this without manually adding versions? Since this is an upgrade, this component (and happens with all other components) is being used all over, it will be very difficult to go add versions all over across all languages.