public ActionResult Index(string alias, string textSearch, int pageIndex = 1) { int cateId = 0; if (!string.IsNullOrEmpty(textSearch)) { textSearch = textSearch.Replace('-', ' '); textSearch = StringUtils.UnicodeToUnsignChar(textSearch); } SearchProduct searchInfo = new SearchProduct() { CateId = cateId, TextSearch = textSearch, OrderBy = CookieManager.Instance.Get <int>(Const.ArrangeProduct).ToInt(0), PageIndex = pageIndex, PageSize = Const.PageSizeProduct }; #region Redirect Permanent 301 string standardUrl = _buildLinkBo.ParserProductUrl(alias, ref searchInfo); string url301 = standardUrl; string currentUrl = Request.RawUrl; if (currentUrl.Contains("?utm_source")) { string strUtm = currentUrl.Substring(currentUrl.IndexOf("?utm_source"), currentUrl.Length - currentUrl.IndexOf("?utm_source")); url301 = string.Concat(url301, strUtm); } if (!currentUrl.Equals(url301)) { return(Redirect301(url301)); } #endregion ProductListModel model = new ProductListModel(); int totalRows = _productBo.GetListCount(searchInfo); if (totalRows > 0) { model.ProductList = _productBo.GetList(searchInfo); #region paging Pagings pageModel = new Pagings { PageIndex = pageIndex, Count = totalRows, LinkSite = Utils.GetCurrentURL(standardUrl, pageIndex), PageSize = Const.PageSizeProduct }; model.PagingInfo = pageModel; ViewBag.MetaPagination = SEO.MetaPagination(pageModel.Count, pageIndex, pageModel.PageSize, pageModel.LinkSite); #endregion } if (pageIndex > 1 && totalRows > 0 && (model.ProductList == null || model.ProductList.Count == 0)) { return(Redirect(model.PagingInfo.LinkSite)); } model.SearchInfo = searchInfo; #region Meta //string titlePage = Const.MetaMainTitle; //string metaTitle = titlePage; //string metaDescription = Const.MetaMainDescription; //string metaKeyword = Const.MetaMainKeyword; MetaModel metaTag = _buildLinkBo.BuildMetaProduct(searchInfo); string metaTags = SEO.Instance.BindingMeta(standardUrl, metaTag.MetaTitle, metaTag.MetaDescription, metaTag.MetaKeyword); model.TitlePage = metaTag.TitlePage; ViewBag.MetaTitle = metaTag.MetaTitle; ViewBag.Meta = metaTags; #endregion return(View(model)); }