public ActionResult Details(string url) { int id; if (int.TryParse(url, out id)) { string oldUrl = _context.GetArticleUrlById(id); if (!string.IsNullOrEmpty(oldUrl)) { return(RedirectToActionPermanent("Details", new { url = oldUrl })); } } var modelDb = _context.GetArticle(url); if (modelDb == null) { return(RedirectToAction("Index")); } var model = Mapper.Map <NewsDetailsVm>(modelDb); model.SimilarNews = Mapper.Map <List <ArticleBaseVm> >(_context.GetOtherNews(model.ArticleId)); ViewBag.Keywords = model.Tags; ViewBag.Description = model.ShortInfoCutted(150); if (Request.Url != null) { ViewBag.OgImage = string.Format("{0}{1}", Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, string.Empty), model.PictureUrlSmall); } return(View(model)); }