The model item passed into the dictionary is of type ‘mvc.Models.ModelA’ but this dictionary requires a model item of type ‘mvc.Models.ModelB‘

Even if the types match, you can get this error when a null is passed to a partial view.

You can fix this by calling RenderPartial with an empty ViewDataDictionary like this:

helper.RenderPartial("~/Views/Player/PlayerName.ascx", player, new ViewDataDictionary());

For reference, I found this solution at:
renderpartial with null model gets passed the wrong type

Leave a Comment

tech