【发布时间】:2016-01-01 19:39:27
【问题描述】:
您好,是否可以在没有模型的视图中运行带有模型的 PartialView,或者我必须创建包含部分视图模型的模型? 示例:
User have his site:
@{
ViewBag.Title = "MyPanel";
}
<div class="jumbotron">
<!--Right Menu-->
<div id="RightMenu" class="col-md-10" style="max-height:550px; overflow-y:scroll;">
@Html.Action("AllSongs","UserPanel")
</div>
</div>
</div>
我想渲染包含模型的 PartialView AllSongs。
public PartialViewResult AllSongs() {
var userId = (int)Session["Login"];
var songs = context.Songs.Where(x => x.UserID.Equals(userId));
return PartialView(songs);
}
但是当代码进入这个方法时,我得到了这样的错误:
Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-partialview