I have been looking at this error for quite some time, and can’t seem to figure out what I might have done wrong.
I have a partial view which is added like this:
<% Html.RenderPartial("~/Views/ForumPosts/ForumPostCreateForm.ascx", ViewData.Model); %>
And the top of the partial view looks like this:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewUserControl<xxxx.Web.Controllers.ForumThreadsController.ForumThreadFormViewModel>" %>
The error I receive is the following:
The model item passed into the dictionary is of type ‘xxx.Core.ForumThread’, but this dictionary requires a model item of type ‘xxx.Web.Controllers.ForumThreadsController+ForumThreadFormViewModel’.
If am not mistaken both takes the model called ForumThread, but apparently I must have missed something.
According to the code you posted, the partial view takes a
xxxx.Web.Controllers.ForumThreadsController.ForumThreadFormViewModel. Either change the top of your partial view, or find some way to pass aForumThreadFormViewModelalong on aForumThreadobject.Another solution would be to use
RenderActionto allow an action to generate theForumThreadFormViewModelyou want.