public IActionResult Detail(int id) { var paper = paperManager.FindPaperById(id); var topicIdList = JsonConvert.DeserializeObject <List <TopicId> >(paper.body); var topicIdTitleList = new List <TopicIdTitle>(); foreach (var item in topicIdList) { var theTopic = topicManager.FindTitleById(item.id); if (theTopic == null) { paperManager.CheckBodyById(id); return(RedirectToAction("Detail", id)); } topicIdTitleList.Add( new TopicIdTitle { id = item.id, title = theTopic } ); } ViewBag.Paper = paper; ViewBag.TopicIdList = topicIdTitleList; return(View()); }