private void CheckFor301(string slug) { MerchantTribe.Commerce.Content.CustomUrl url = MTApp.ContentServices.CustomUrls.FindByRequestedUrl(slug); if (url != null) { if (url.Bvin != string.Empty) { if (url.IsPermanentRedirect) { Response.RedirectPermanent(url.RedirectToUrl); } else { Response.Redirect(url.RedirectToUrl); } } } }
private bool Save() { bool result = false; if (UrlRewriter.IsUrlInUse(this.RequestedUrlField.Text.Trim(), this.BvinField.Value, MTApp.CurrentRequestContext, MTApp)) { this.MessageBox1.ShowWarning("Another item already uses this URL. Please choose another one"); return false; } CustomUrl c; c = MTApp.ContentServices.CustomUrls.Find(this.BvinField.Value); if (c == null) c = new CustomUrl(); if (c != null) { c.RequestedUrl = this.RequestedUrlField.Text.Trim(); c.RedirectToUrl = this.RedirectToUrlField.Text.Trim(); c.IsPermanentRedirect = this.chkPermanent.Checked; if (this.BvinField.Value == string.Empty) { result = MTApp.ContentServices.CustomUrls.Create(c); } else { result = MTApp.ContentServices.CustomUrls.Update(c); } if (result == true) { // Update bvin field so that next save will call updated instead of create this.BvinField.Value = c.Bvin; } } return result; }
public ActionResult Error() { ViewBag.Title = MTApp.CurrentStore.StoreName; Response.StatusCode = 404; string type = Request.QueryString["type"]; if (string.Compare(type, "product", true) == 0) { ViewBag.ErrorHeader = SiteTerms.GetTerm(SiteTermIds.ErrorPageHeaderTextProduct); ViewBag.ErrorContent = SiteTerms.GetTerm(SiteTermIds.ErrorPageContentTextProduct); if (ViewBag.ErrorHeader == string.Empty) { ViewBag.ErrorHeader = "Error finding product"; } if (ViewBag.ErrorContent == string.Empty) { ViewBag.ErrorContent = "An error occurred while trying to find the specified product."; } Response.StatusDescription = "Product Not Found"; } else if (string.Compare(type, "category", true) == 0) { ViewBag.ErrorHeader = SiteTerms.GetTerm(SiteTermIds.ErrorPageHeaderTextCategory); ViewBag.ErrorContent = SiteTerms.GetTerm(SiteTermIds.ErrorPageContentTextCategory); if (ViewBag.ErrorHeader == string.Empty) { ViewBag.ErrorHeader = "Error finding category"; } if (ViewBag.ErrorContent == string.Empty) { ViewBag.ErrorContent = "An error occurred while trying to find the specified category."; } Response.StatusDescription = "Category Not Found"; } else { string requested = string.Empty; if (Request.QueryString["aspxerrorpath"] != null) { requested = Request.QueryString["aspxerrorpath"]; } else { requested = Request.RawUrl; } MerchantTribe.Commerce.Content.CustomUrl url = MTApp.ContentServices.CustomUrls.FindByRequestedUrl(requested); if (url != null) { if (url.Bvin != string.Empty) { if (url.IsPermanentRedirect) { Response.RedirectPermanent(url.RedirectToUrl); } else { Response.Redirect(url.RedirectToUrl); } } } ViewBag.ErrorHeader = SiteTerms.GetTerm(SiteTermIds.ErrorPageHeaderTextGeneric); ViewBag.ErrorContent = SiteTerms.GetTerm(SiteTermIds.ErrorPageContentTextGeneric); if (ViewBag.ErrorHeader == string.Empty) { ViewBag.ErrorHeader = "Error finding page"; } if (ViewBag.ErrorContent == string.Empty) { ViewBag.ErrorContent = "An error occurred while processing your request."; } } return(View()); }