public ActionResult TagItems(string key, int pageNumber = 1) { var model = new Contents(); model.GetContentAllPageWiseKey(pageNumber, PageSize, key.Replace("-", " ")); if (model.Count == 0) { // this might have had a dash in it model.GetContentPageWiseKeyRelease(1, PageSize, ViewBag.KeyName); if (model.Count == 0) { // TODO: combination of with and without, deal with it } } var sb = new StringBuilder(); foreach (Content cnt in model) { sb.Append(cnt.ToUnorderdListItem); } return Json(new { ListItems = sb.ToString(), JsonRequestBehavior.AllowGet }); }