public IActionResult Home(int page) { Ads ad = new Ads(@"Data Source=.\sqlexpress;Initial Catalog=ADS;Integrated Security=True;"); AdViewModel vm = new AdViewModel(); if (page <= 0) { page = 1; } int pagecount = 3; if (page > 1) { vm.NextPage = page - 1; } int from = (page - 1) * pagecount; int to = from + pagecount; int total = ad.GetCount(); if (to < total) { vm.PreviousPage = page + 1; } vm.Ad = ad.Get3(from, pagecount); List <int> x = new List <int>(); if (HttpContext.Session.Get <List <int> >("user") != null) { x = HttpContext.Session.Get <List <int> >("user"); } vm.UserId = x; return(View(vm)); }