public ActionResult Http404()
        {
            string storeLink;

            try
            {
                storeLink = _linkGenerator.GenerateStoreLink();
            }
            catch (Exception)
            {
                storeLink = "http://www.MicrosoftStore.com";
            }

            return(View("404", (object)storeLink));
        }
        // redirect if config says there's a switcheroo
        protected bool GetRedirectFromConfig(long categoryId, ref ActionResult redirectResult)
        {
            var catRed = CategoryRedirectConfig.GetCategoryRedirect(categoryId);

            if (catRed != null)
            {
                switch (catRed.ToWhat)
                {
                case CategoryRedirectToWhat.CategoryId:
                    if (catRed.Value != categoryId.ToString(CultureInfo.InvariantCulture))
                    // don't do infinite redirect loop infinite redirect loop infinite redirect loop infinite redirect ...
                    {
                        redirectResult =
                            RedirectPermanent(
                                this.AssureHttpUrl(LinkGenerator.GenerateCategoryLink(long.Parse(catRed.Value))));
                        return(true);
                    }
                    break;

                case CategoryRedirectToWhat.ProductId:
                    long pid;
                    redirectResult =
                        RedirectPermanent(this.AssureHttpUrl(LinkGenerator.GenerateProductLink(long.TryParse(catRed.Value, out pid) ? pid : (long?)null)));
                    return(true);

                case CategoryRedirectToWhat.Path:
                    // gen url based on store link minus last segment for store itself
                    var storeLink = _linkGenerator.GenerateStoreLink();
                    if (!string.IsNullOrEmpty(storeLink))
                    {
                        var lastSlashIdx = storeLink.LastIndexOf('/');
                        if (lastSlashIdx >= 0)
                        {
                            var redirectUrl = storeLink.Substring(0, lastSlashIdx);
                            if (!catRed.Value.StartsWith("/"))
                            {
                                redirectUrl += "/";
                            }
                            redirectUrl   += catRed.Value;
                            redirectResult = RedirectPermanent(this.AssureHttpUrl(redirectUrl));
                            return(true);
                        }
                    }
                    break;
                }
            }
            return(false);
        }
        private bool GetRedirectFromConfig(long categoryId)
        {
            var catRed = GetCategoryRedirect(categoryId);

            if (catRed == null)
            {
                return(false);
            }

            long catredId;

            if (!long.TryParse(catRed.Value, out catredId))
            {
                return(false);
            }

            switch (catRed.ToWhat)
            {
            case CategoryRedirectToWhat.CategoryId:
                if (catredId != categoryId)
                {
                    return(true);
                }
                break;

            case CategoryRedirectToWhat.ProductId:
                return(true);

            case CategoryRedirectToWhat.Path:
            {
                // gen url based on store link minus last segment for store itself
                var storeLink = _linkGenerator.GenerateStoreLink();
                if (!string.IsNullOrEmpty(storeLink))
                {
                    var lastSlashIdx = storeLink.LastIndexOf('/');
                    if (lastSlashIdx >= 0)
                    {
                        return(true);
                    }
                }
            }
            break;
            }
            return(false);
        }
        public override ActionResult Index()
        {
            if (CurrentItem == null)
            {
                throw new Exception();
            }

            AssertProductsLoaded();

            var redirectUrl = CurrentItem.GetUrl(_linkGenerator);

            if (IsManaging)
            {
                return(Content(string.Format(AdminDisplayHtml, redirectUrl + Request.Url.Query ?? "(unspecified)"),
                               "text/html; charset=UTF-8"));
            }

            return(string.IsNullOrEmpty(redirectUrl)
                ? Redirect(_linkGenerator.GenerateStoreLink())
                : RedirectPermanent(redirectUrl + Request.Url.Query));
        }