我有,我有一個模型指定爲這樣的局部視圖:局部視圖加載錯誤的模型
@model IEnumerable<AbstractThinking2015.Models.BlogModel>
@foreach (var item in Model.Take(5))
{
<li>@Html.ActionLink(item.Title, "Details", new { id = item.BlogModelId })</li>
}
我打電話這一點使用:
<div class="widget">
<h4>Recent Posts</h4>
<ul>
@Html.Partial("View")
</ul>
</div>
但我發現了錯誤:
The model item passed into the dictionary is of type 'AbstractThinking2015.Models.BlogModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[AbstractThinking2015.Models.BlogModel]'.
我敢肯定,這是因爲該模型被傳遞到視圖是一個博客,但我想用在部分視圖中定義的列表。有沒有辦法做到這一點?
你的主視圖渲染是什麼? – Shyju
目前它只是打破,但它使用的模型是:@model AbstractThinking2015.Models.BlogModel –