I think the easiest way to create pagination in ASP.NET MVC application is using PagedList library.
There is a complete example in following github repository. Hope it would help.
public class ProductController : Controller
{
public object Index(int? page)
{
var list = ItemDB.GetListOfItems();
var pageNumber = page ?? 1;
var onePageOfItem = list.ToPagedList(pageNumber, 25); // will only contain 25 items max because of the pageSize
ViewBag.onePageOfItem = onePageOfProducts;
return View();
}
}
Demo Link: http://ajaxpagination.azurewebsites.net/
Source Code: https://github.com/ungleng/SimpleAjaxPagedListAndSearchMVC5