这是我返回帖子列表的 MVC 操作:
public ActionResult Posts()
{
var blogPost = _blogRepository.GetAllPost();
var blogPostViewModel = blogPost.ConvertToPostViewModelList();
return View("Posts", blogPostViewModel);
}
这也是我的观点
@model IEnumerable<Blog.Web.UI.ViewModels.PostViewModel>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div>
@foreach (var item in Model)
{
<div>
<h3>
@Html.ActionLink(item.Title, "Post", "Blog", new { postId = item.Id, postSlug = item.UrlSlug }, null)
</h3>
</div>
<div>
<span>Category: </span>@item.Category.Name
</div>
<div>
<span>Tag: </span>@item.Tag.Name
</div>
<div>
@item.CreationDate.ToLongDateString()
</div>
<div>
@Html.DisplayTextFor(p => item.Body)
</div>
}
</div>
我想为此页面实现一个客户端分页,按日期呈现所有帖子,这可能吗?或者我应该更改我的代码以使其成为服务器端?