public ActionResult Index(string tag, int?page) { int pagesize = 10; int pagenumber = (page ?? 1); var user = profileRepository.GetByID(WebSecurity.CurrentUserId); if (user.Profile != null) { pagesize = user.Profile.NumerOfResults; } if (string.IsNullOrEmpty(tag)) { var works = workRepository.GetAll().Reverse(); return(View(works.ToPagedList(pagenumber, pagesize))); } var workswithtags = workRepository.GetWhere(x => x.Tags.Contains(tag)); return(View(workswithtags.ToPagedList(pagenumber, pagesize))); }