示例#1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void Page_Load(object sender, EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                m_SkinBase.GoNonSecureAgain();
            }

            n = m_EntityHelper.m_TblMgr.SetContext(m_EntityInstanceID);
            //Determine if the entity is map to the current store.
            if (n == null)
            {
                HttpContext.Current.Server.Transfer("pagenotfound.aspx");
            }
            //Checking for multi store.
            CachelessStore store = new CachelessStore();

            store.StoreID = AppLogic.StoreID();
            MappedObject map = store.GetMapping(m_EntitySpecs.m_EntityName, m_EntityInstanceID);

            if (AppLogic.GlobalConfigBool("AllowEntityFiltering") == true && !map.IsMapped)
            {
                HttpContext.Current.Server.Transfer("pagenotfound.aspx");
            }
            m_ThisEntityNodeContext = n;

            String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");

            if (SENameINURL.Equals(XmlCommon.XmlField(GetActiveEntityNodeContext, "SEName"), StringComparison.InvariantCultureIgnoreCase) == false)
            {
                string QS     = BuildQueryString();
                String NewURL = string.Format("{0}{1}{2}", AppLogic.GetStoreHTTPLocation(false, false), SE.MakeEntityLink(m_EntityHelper.GetEntitySpecs.m_EntityName, m_EntityInstanceID, XmlCommon.XmlField(GetActiveEntityNodeContext, "SEName")), QS);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                HttpContext.Current.Response.Status = "301 Moved Permanently";
                HttpContext.Current.Response.AddHeader("Location", NewURL);
                m_URLValidated = false;
            }

            if (m_URLValidated)
            {
                m_CategoryFilterID     = CommonLogic.QueryStringUSInt("CategoryFilterID");
                m_SectionFilterID      = CommonLogic.QueryStringUSInt("SectionFilterID");
                m_ProductTypeFilterID  = CommonLogic.QueryStringUSInt("ProductTypeFilterID");
                m_ManufacturerFilterID = CommonLogic.QueryStringUSInt("ManufacturerFilterID");
                m_DistributorFilterID  = CommonLogic.QueryStringUSInt("DistributorFilterID");
                m_GenreFilterID        = CommonLogic.QueryStringUSInt("GenreFilterID");
                m_VectorFilterID       = CommonLogic.QueryStringUSInt("VectorFilterID");

                if (CommonLogic.QueryStringCanBeDangerousContent("CategoryFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") && CommonLogic.CookieUSInt("CategoryFilterID") != 0)
                    {
                        m_CategoryFilterID = CommonLogic.CookieUSInt("CategoryFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("SectionFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") && CommonLogic.CookieUSInt("SectionFilterID") != 0)
                    {
                        m_SectionFilterID = CommonLogic.CookieUSInt("SectionFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("ProductTypeFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") && CommonLogic.CookieUSInt("ProductTypeFilterID") != 0)
                    {
                        m_ProductTypeFilterID = CommonLogic.CookieUSInt("ProductTypeFilterID");
                    }
                    if (m_ProductTypeFilterID != 0 &&
                        !AppLogic.ProductTypeHasVisibleProducts(m_ProductTypeFilterID))
                    {
                        m_ProductTypeFilterID = 0;
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("ManufacturerFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("ManufacturerFilterID") != 0)
                    {
                        m_ManufacturerFilterID = CommonLogic.CookieUSInt("ManufacturerFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("DistributorFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("DistributorFilterID") != 0)
                    {
                        m_DistributorFilterID = CommonLogic.CookieUSInt("DistributorFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("GenreFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("GenreFilterID") != 0)
                    {
                        m_GenreFilterID = CommonLogic.CookieUSInt("GenreFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("VectorFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("VectorFilterID") != 0)
                    {
                        m_VectorFilterID = CommonLogic.CookieUSInt("VectorFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length != 0)
                {
                    m_CategoryFilterID     = 0;
                    m_SectionFilterID      = 0;
                    m_ManufacturerFilterID = 0;
                    m_DistributorFilterID  = 0;
                    m_GenreFilterID        = 0;
                    m_VectorFilterID       = 0;
                    m_ProductTypeFilterID  = 0;
                }

                if (AppLogic.AppConfigBool("PersistFilters"))
                {
                    HttpContext.Current.Profile.SetPropertyValue("CategoryFilterID", m_CategoryFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("SectionFilterID", m_SectionFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("ManufacturerFilterID", m_ManufacturerFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("DistributorFilterID", m_DistributorFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("GenreFilterID", m_GenreFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("VectorFilterID", m_VectorFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("ProductTypeFilterID", m_ProductTypeFilterID.ToString());
                }

                m_EntityInstanceName = m_EntityHelper.m_TblMgr.CurrentName(n, m_SkinBase.ThisCustomer.LocaleSetting);

                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityName", m_EntitySpecs.m_EntityName);
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceID", m_EntityInstanceID.ToString());
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceName", m_EntityInstanceName);

                #region Vortx Mobile Xml Package Modification
                m_XmlPackage = Vortx.MobileFramework.MobileXmlPackageController.XmlPackageHook(m_EntityHelper.m_TblMgr.CurrentField(n, "XmlPackage").ToLowerInvariant(), m_SkinBase.ThisCustomer);
                #endregion
                if (m_XmlPackage.Length == 0)
                {
                    m_XmlPackage = AppLogic.ro_DefaultEntityXmlPackage; // provide a default for backwards compatibility
                }


                String RunTimeParms = String.Format("EntityName={0}&EntityID={1}", m_EntitySpecs.m_EntityName, m_EntityInstanceID.ToString());

                RunTimeParms += String.Format("&CatID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("CATEGORY", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_CategoryFilterID.ToString()));
                RunTimeParms += String.Format("&SecID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("SECTION", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_SectionFilterID.ToString()));
                RunTimeParms += String.Format("&ManID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("MANUFACTURER", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_ManufacturerFilterID.ToString()));
                RunTimeParms += String.Format("&DistID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("DISTRIBUTOR", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_DistributorFilterID.ToString()));
                RunTimeParms += String.Format("&GenreID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("GENRE", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_GenreFilterID.ToString()));
                RunTimeParms += String.Format("&VectorID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("VECTOR", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_VectorFilterID.ToString()));
                RunTimeParms += String.Format("&ProductTypeFilterID={0}", m_ProductTypeFilterID.ToString());

                // CacheEntityPageHTML is an UNSUPPORTED and UNDOCUMENTED AppConfig
                // caching does NOT honor cross entity filtering, or other filters. Use it only on high traffic sites
                // with entity pages that do NOT vary by params other than those used in the CacheName string below.
                // if you are showing prices, they will remain the same during the cache duration (AppLogic.CacheDurationMinutes setting, usually 1 hr)
                String CacheName = String.Empty;


                m_SkinBase.SETitle = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SETitle", m_SkinBase.ThisCustomer.LocaleSetting);
                if (m_SkinBase.SETitle.Length == 0)
                {
                    m_SkinBase.SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + m_EntityInstanceName);
                }
                m_SkinBase.SEDescription = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEDescription", m_SkinBase.ThisCustomer.LocaleSetting);
                if (m_SkinBase.SEDescription.Length == 0)
                {
                    m_SkinBase.SEDescription = Security.HtmlEncode(m_EntityInstanceName);
                }
                m_SkinBase.SEKeywords = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEKeywords", m_SkinBase.ThisCustomer.LocaleSetting);
                if (m_SkinBase.SEKeywords.Length == 0)
                {
                    m_SkinBase.SEKeywords = Security.HtmlEncode(m_EntityInstanceName);
                }
                m_SkinBase.SENoScript = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SENoScript", m_SkinBase.ThisCustomer.LocaleSetting);

                m_SkinBase.SectionTitle = Breadcrumb.GetEntityBreadcrumb(m_EntityInstanceID, m_EntityInstanceName, m_EntitySpecs.m_EntityName, m_SkinBase.ThisCustomer);

                if (m_URLValidated)
                {
                    m_PageOutput = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                    if (m_XmlPackage.Length == 0)
                    {
                        m_PageOutput += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                    }
                    else
                    {
                        String s = null;
                        if (AppLogic.AppConfigBool("CacheEntityPageHTML"))
                        {
                            CacheName = String.Format("CacheEntityPageHTML|{0}|{1}|{2}|{3}|{4}|{5}|{6}",
                                                      m_EntitySpecs.m_EntityName,
                                                      m_EntityInstanceID.ToString(),
                                                      m_SkinBase.ThisCustomer.CustomerLevelID.ToString(),
                                                      m_SkinBase.ThisCustomer.LocaleSetting,
                                                      CommonLogic.QueryStringUSInt("PageNum").ToString(),
                                                      m_SkinBase.ThisCustomer.AffiliateID.ToString(),
                                                      Vortx.MobileFramework.MobileHelper.isMobile() ? "Mobile" : "Desktop"
                                                      );

                            s = (String)HttpContext.Current.Cache.Get(CacheName);
                            if (s != null)
                            {
                                s = "<!-- CacheEntityPageHTML -->" + s;
                            }
                            m_SkinBase.SectionTitle  = (String)HttpContext.Current.Cache.Get(CacheName + "|SectionTitle");
                            m_SkinBase.SETitle       = (String)HttpContext.Current.Cache.Get(CacheName + "|SETitle");
                            m_SkinBase.SEDescription = (String)HttpContext.Current.Cache.Get(CacheName + "|SEDescription");
                            m_SkinBase.SEKeywords    = (String)HttpContext.Current.Cache.Get(CacheName + "|SEKeywords");
                            m_SkinBase.SENoScript    = (String)HttpContext.Current.Cache.Get(CacheName + "|SENoScript");
                            if (m_SkinBase.SectionTitle == null)
                            {
                                m_SkinBase.SectionTitle = String.Empty;
                            }
                            if (m_SkinBase.SETitle == null)
                            {
                                m_SkinBase.SETitle = String.Empty;
                            }
                            if (m_SkinBase.SEDescription == null)
                            {
                                m_SkinBase.SEDescription = String.Empty;
                            }
                            if (m_SkinBase.SEKeywords == null)
                            {
                                m_SkinBase.SEKeywords = String.Empty;
                            }
                            if (m_SkinBase.SENoScript == null)
                            {
                                m_SkinBase.SENoScript = String.Empty;
                            }
                        }
                        if (s == null || s.Length == 0)
                        {
                            using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, m_SkinBase.ThisCustomer, m_SkinBase.SkinID, "", RunTimeParms, String.Empty, true))
                            {
                                s = AppLogic.RunXmlPackage(p, m_SkinBase.GetParser, m_SkinBase.ThisCustomer, m_SkinBase.SkinID, true, true);
                                if (p.SectionTitle != "")
                                {
                                    m_SkinBase.SectionTitle = p.SectionTitle;
                                }
                                if (p.SETitle != "")
                                {
                                    m_SkinBase.SETitle = p.SETitle;
                                }
                                if (p.SEDescription != "")
                                {
                                    m_SkinBase.SEDescription = p.SEDescription;
                                }
                                if (p.SEKeywords != "")
                                {
                                    m_SkinBase.SEKeywords = p.SEKeywords;
                                }
                                if (p.SENoScript != "")
                                {
                                    m_SkinBase.SENoScript = p.SENoScript;
                                }
                                if (AppLogic.AppConfigBool("CacheEntityPageHTML"))
                                {
                                    HttpContext.Current.Cache.Insert(CacheName, s, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SectionTitle", p.SectionTitle, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SETitle", p.SETitle, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SEDescription", p.SEDescription, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SEKeywords", p.SEKeywords, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SENoScript", p.SENoScript, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                }
                            }
                        }
                        m_PageOutput += s;
                    }
                }
            }
            AppLogic.eventHandler("ViewEntityPage").CallEvent("&ViewEntityPage=true");

            //check if the postback was caused by the TableOrderAddToCart button
            if (m_SkinBase.IsPostBack && isTableOrderAddToCartPostBack)
            {
                HandleTableOrderAddToCart();
            }
        }
        public ActionResult Detail(int id, string entityType, string searchEngineName, int?productTypeFilterId)
        {
            var normalizedEntityType = AppLogic.ro_SupportedEntities
                                       .Intersect(new[] { entityType }, StringComparer.OrdinalIgnoreCase)
                                       .FirstOrDefault();

            if (normalizedEntityType == null)
            {
                throw new HttpException(404, string.Format("Unsupported entity type: {0}", entityType));
            }

            var entity   = new Entity(id, normalizedEntityType);
            var customer = ControllerContext.HttpContext.GetCustomer();

            //Make sure we've got a valid entity
            if (entity == null ||
                entity.ID == 0 ||
                entity.Published == false ||
                entity.Deleted == true)
            {
                throw new HttpException(404, null);
            }

            //Make sure that this entity is mapped to this store
            var store = new CachelessStore();

            store.StoreID = AppLogic.StoreID();
            var storeMapping = store.GetMapping(entity.EntityType, entity.ID);

            if (AppLogic.GlobalConfigBool("AllowEntityFiltering") == true && !storeMapping.IsMapped)
            {
                throw new HttpException(404, null);
            }

            //301 Redirect to the correct search engine name in the url if it is wrong
            if (!StringComparer.OrdinalIgnoreCase.Equals(searchEngineName, entity.SEName))
            {
                return(RedirectPermanent(Url.BuildEntityLink(normalizedEntityType, id, entity.SEName)));
            }

            //Set last seen values on the profile
            HttpContext.Profile.SetPropertyValue("LastViewedEntityName", entity.EntityType);
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceID", entity.ID.ToString());
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceName", XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true));

            //Build up the runtime parameters for the xmlpackage
            var runtimeParameters = string.Format("EntityName={0}&EntityID={1}&ProductTypeFilterID={2}",
                                                  entity.EntityType,
                                                  entity.ID,
                                                  productTypeFilterId ?? 0);

            var entityTypeSpecificRuntimeParamName = "CatID";

            if (entity.EntityType.Equals("manufacturer", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "ManID";
            }
            else if (entity.EntityType.Equals("section", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "SecID";
            }
            else if (entity.EntityType.Equals("distributor", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "DistID";
            }
            else if (entity.EntityType.Equals("genre", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "GenreID";
            }
            else if (entity.EntityType.Equals("vector", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "VectorID";
            }
            else if (entity.EntityType.Equals("section", StringComparison.InvariantCultureIgnoreCase))
            {
                entityTypeSpecificRuntimeParamName = "DistID";
            }

            runtimeParameters += string.Format("&{0}={1}", entityTypeSpecificRuntimeParamName, entity.ID);

            //Get a default xmlpackage if we don't have one specified in the database
            var xmlPackageName = string.IsNullOrEmpty(entity.XmlPackage)
                                ? AppLogic.ro_DefaultEntityXmlPackage
                                : entity.XmlPackage;

            //Setup Meta tags
            var metaTitle = XmlCommon.GetLocaleEntry(entity.SETitle, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaTitle))
            {
                metaTitle = string.Format("{0} - {1}", AppLogic.AppConfig("StoreName"), entity.LocaleName);
            }

            var metaDescription = XmlCommon.GetLocaleEntry(entity.SEDescription, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaDescription))
            {
                metaDescription = entity.LocaleName;
            }

            var metaKeywords = XmlCommon.GetLocaleEntry(entity.SEKeywords, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaKeywords))
            {
                metaKeywords = entity.LocaleName;
            }

            //Setup the breadcrumb
            var pageTitle = Breadcrumb.GetEntityBreadcrumb(entity.ID, entity.LocaleName, entity.EntityType, customer);

            //Get the page content from the xmlpackage
            var pageContent = string.Empty;
            var xmlPackage  = new XmlPackage(
                packageName: xmlPackageName,
                customer: customer,
                additionalRuntimeParms: runtimeParameters,
                htmlHelper: ControllerContext.GetHtmlHelper());

            var parser = new Parser();

            pageContent = AppLogic.RunXmlPackage(xmlPackage, parser, customer, customer.SkinID, true, true);
            //override the meta tags from the xmlpackage
            if (xmlPackage.SETitle != string.Empty)
            {
                metaTitle = xmlPackage.SETitle;
            }
            if (xmlPackage.SEDescription != string.Empty)
            {
                metaDescription = xmlPackage.SEDescription;
            }
            if (xmlPackage.SEKeywords != string.Empty)
            {
                metaKeywords = xmlPackage.SEKeywords;
            }
            if (xmlPackage.SectionTitle != string.Empty)
            {
                pageTitle = xmlPackage.SectionTitle;
            }

            var payPalAd = new PayPalAd(PayPalAd.TargetPage.Entity);

            //Build the view model
            var entityViewModel = new EntityViewModel
            {
                Name            = XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true),
                MetaTitle       = metaTitle,
                MetaDescription = metaDescription,
                MetaKeywords    = metaKeywords,
                PageTitle       = pageTitle,
                PageContent     = pageContent,
                PayPalAd        = payPalAd.ImageMarkup,
                XmlPackageName  = xmlPackageName
            };

            AppLogic.eventHandler("ViewEntityPage").CallEvent("&ViewEntityPage=true");


            //Override the layout
            var layoutName = string.Empty;

            if (AppLogic.AppConfigBool("TemplateSwitching.Enabled"))
            {
                layoutName = AppLogic.GetCurrentEntityTemplateName(entity.EntityType, entity.ID);
            }

            if (!string.IsNullOrEmpty(layoutName))
            {
                return(View(ActionNames.Detail, layoutName, entityViewModel));
            }
            else
            {
                return(View(entityViewModel));
            }
        }
示例#3
0
        public ActionResult Index(int categoryid, string searchEngineName)

        {
            var entity   = new Entity(categoryid, "category");
            var customer = ControllerContext.HttpContext.GetCustomer();

            //Make sure we've got a valid entity
            if (entity == null ||
                entity.ID == 0 ||
                entity.Published == false ||
                entity.Deleted == true)
            {
                throw new HttpException(404, null);
            }

            //Make sure that this entity is mapped to this store
            var store = new CachelessStore();

            store.StoreID = AppLogic.StoreID();
            var storeMapping = store.GetMapping(entity.EntityType, entity.ID);

            if (AppLogic.GlobalConfigBool("AllowEntityFiltering") == true && !storeMapping.IsMapped)
            {
                throw new HttpException(404, null);
            }

            //Set last seen values on the profile
            HttpContext.Profile.SetPropertyValue("LastViewedEntityName", entity.EntityType);
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceID", entity.ID.ToString());
            HttpContext.Profile.SetPropertyValue("LastViewedEntityInstanceName", XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true));

            //Build up the runtime parameters for the xmlpackage
            var runtimeParameters = string.Format("EntityName={0}&EntityID={1}&ProductTypeFilterID=0",
                                                  entity.EntityType,
                                                  entity.ID);

            var entityTypeSpecificRuntimeParamName = "CatID";

            runtimeParameters += string.Format("&{0}={1}", entityTypeSpecificRuntimeParamName, entity.ID);

            //Get a default xmlpackage if we don't have one specified in the database
            var xmlPackageName = string.IsNullOrEmpty(entity.XmlPackage)
                ? "category.xml.config"
                : entity.XmlPackage;

            //Setup Meta tags
            var metaTitle = XmlCommon.GetLocaleEntry(entity.SETitle, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaTitle))
            {
                metaTitle = Security.HtmlEncode(string.Format("{0} - {1}", AppLogic.AppConfig("StoreName"), entity.LocaleName));
            }

            var metaDescription = XmlCommon.GetLocaleEntry(entity.SEDescription, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaDescription))
            {
                metaDescription = Security.HtmlEncode(entity.LocaleName);
            }

            var metaKeywords = XmlCommon.GetLocaleEntry(entity.SEKeywords, customer.LocaleSetting, true);

            if (string.IsNullOrEmpty(metaKeywords))
            {
                metaKeywords = Security.HtmlEncode(entity.LocaleName);
            }

            //Setup the breadcrumb
            var pageTitle = Breadcrumb.GetEntityBreadcrumb(entity.ID, entity.LocaleName, entity.EntityType, customer);

            //Get the page content from the xmlpackage
            var pageContent = string.Empty;
            var xmlPackage  = new XmlPackage(
                packageName: xmlPackageName,
                customer: customer,
                additionalRuntimeParms: runtimeParameters,
                htmlHelper: ControllerContext.GetHtmlHelper());

            var parser = new Parser();

            pageContent = AppLogic.RunXmlPackage(xmlPackage, parser, customer, customer.SkinID, true, true);
            //override the meta tags from the xmlpackage
            if (xmlPackage.SETitle != string.Empty)
            {
                metaTitle = xmlPackage.SETitle;
            }
            if (xmlPackage.SEDescription != string.Empty)
            {
                metaDescription = xmlPackage.SEDescription;
            }
            if (xmlPackage.SEKeywords != string.Empty)
            {
                metaKeywords = xmlPackage.SEKeywords;
            }
            if (xmlPackage.SectionTitle != string.Empty)
            {
                pageTitle = xmlPackage.SectionTitle;
            }

            var payPalAd = new PayPalAd(PayPalAd.TargetPage.Entity);

            //Build the view model
            var entityViewModel = new EntityViewModel
            {
                Name            = XmlCommon.GetLocaleEntry(entity.Name, customer.LocaleSetting, true),
                MetaTitle       = metaTitle,
                MetaDescription = metaDescription,
                MetaKeywords    = metaKeywords,
                PageTitle       = pageTitle,
                PageContent     = pageContent,
                PayPalAd        = payPalAd.Show ? payPalAd.ImageScript : string.Empty,
                XmlPackageName  = xmlPackageName
            };

            AppLogic.eventHandler("ViewEntityPage").CallEvent("&ViewEntityPage=true");

            //Override the layout
            var layoutName = string.Empty;

            return(View(entityViewModel));
        }