I want to use @Html.Partial("_partialView") to include a partial view on my page in MVC 3.
Both the page and the viewmodel have a viewmodel; thus, the following error is generated:
The model item passed into the dictionary is of type ‘[…]page’, but
this dictionary requires a model item of type ‘[…]partialview’.
How can I use the @Html.Partial() method while keeping the two viewmodels?
You should use this overload that allows the model object to be passed to partial view
By the way, do you really need to call
Partial?RenderPartialis better – it writes directly to the response stream(compared to partial that returns string), so reserves the memory. Partial views can be quite big, so there’s memory overhead withPartialif you do not absolutely need it.