The book has the following code:
public ActionResult Index(int page = 0) {
...
}
which gives me the following errror: "Default parameter specifiers are not permitted"
To get around this problem I use the following for the Index action method:
//GET: /Dinners/page/2
public ActionResult Index(int? page)
{
int displayPage = null == page ? 0 : (int)page;
const int pageSize = 10;
var dinners = dinnerRepository.FindUpcomingDinners();
var paginatedDinners = dinners.OrderBy(d => d.EventDate)
.Skip(displayPage * pageSize)
.Take(pageSize)
.ToList();
return View(paginatedDinners);
}
The page now works for:
http://localhost:55424/Dinners/page/1
http://localhost:55424/Dinners/