-3
我在博客网站项目中工作。我为博客文章创建了部分视图。部分视图出错
它_MainContent局部视图
@model System.Collections.Generic.IEnumerable<Blog.Data.Model.Article>
@foreach (var item in Model)
{
<div class="panel">
<div class="panel-body">
<div>
<h3>
@Html.ActionLink(item.ArticleTitle, "Index", "Article", new { id = item.ArticleId }, new { })
</h3>
</div>
<div id="img">
<img width="400" height="300" src="@string.Format("data:{0};base64,{1}",item.ArticleImages.FirstOrDefault().ContentType,Convert.ToBase64String(item.ArticleImages.FirstOrDefault().Content))" />
</div>
<div>
<p>
@Html.DisplayFor(x=> item.Content)
</p>
</div>
</div>
</div>
}
而且它的指数
@model System.Collections.Generic.IEnumerable<Blog.Data.Model.Article>
@{
ViewBag.Title = "Anasayfa";
}
<div class="container">
<div class="col-md-offset-10 col-md-2">
@Html.Partial("_SideMenuPartial")
</div>
<div class="col-md-10">
@Html.Partial("_MainContent", Model.FirstOrDefault())
</div>
</div>
页时,我开始那么这个程序发生
An exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll but was not handled in user code
Additional information: The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.Article_E29CF5FDD5B2D2829B35531643263744339081C99736858CE61DDB0981D557EE', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Blog.Data.Model.Article]'.
,我有一个空白页。
阅读错误消息:传入字典的模型项目类型为文章,但该字典需要一个“IEnumerable”类型的模型项 - 它说明了所有内容。 –
原因是我的英文有点不好 – ufukcalimli