这是我的行动:
public ActionResult List()
{
var currentDate = DateTime.Now;
var list = new List<ArchiveViewModel>();
for (var startDate = new DateTime(2012, 11, 1); startDate <= currentDate; startDate = startDate.AddMonths(1))
{
list.Add(new ArchiveViewModel
{
Month = startDate.Month,
Year = startDate.Year,
FormattedDate = startDate.ToString("MMMM, yyyy")
});
}
return View("List",list);
}
这是视图
@model IList<Blog.Web.UI.ViewModels.ArchiveViewModel>
@foreach (var item in Model)
{
@Html.ActionLink(item.FormattedDate, "Post", "Archive", new { month = item.Month, year = item.Year }, null)
}
这个动作结果的输出是这样的
November, 2012
December, 2012
January, 2013
February, 2013
March, 2013
April, 2013
May, 2013
June, 2013
但我想输出这样的东西
June, 2013
May, 2013
April, 2013
March, 2013
...
November, 2012
我怎样才能做到这一点 ??