Exemplo n.º 1
0
        /// <summary>
        /// Initializes the specified rewrite settings.
        /// </summary>
        /// <param name="rewriteSettings">The rewrite settings.</param>
        public override void Initialize(RewriteSettings rewriteSettings)
        {
            base.Initialize(rewriteSettings);

            if (!string.IsNullOrEmpty(rewriteSettings.Attributes["handlerflag"]))
            {
                this.handlerFlag = rewriteSettings.Attributes["handlerflag"].ToLower(CultureInfo.InvariantCulture);
            }

            if (!string.IsNullOrEmpty(rewriteSettings.Attributes["handlersplitter"]))
            {
                this.defaultSplitter = rewriteSettings.Attributes["handlersplitter"];
            }
            else
            {
                if (ConfigurationManager.AppSettings["HandlerDefaultSplitter"] != null)
                {
                    this.defaultSplitter = ConfigurationManager.AppSettings["HandlerDefaultSplitter"];
                }
            }

            if (!string.IsNullOrEmpty(rewriteSettings.Attributes["pageidnosplitter"]))
            {
                bool.Parse(rewriteSettings.Attributes["pageidnosplitter"]);
            }

            if (!string.IsNullOrEmpty(rewriteSettings.Attributes["friendlyPageName"]))
            {
                this.friendlyPageName = rewriteSettings.Attributes["friendlyPageName"];
            }

            // [email protected] - 2014/12/16 - Set friendlyURl from Web.config
            //if (!string.IsNullOrEmpty(rewriteSettings.Attributes["friendlyUrlExtension"]))
            if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["FriendlyUrlExtension"]))
            {
                this.friendlyUrlExtension = System.Configuration.ConfigurationManager.AppSettings["FriendlyUrlExtension"];
            }

            //if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["friendlyUrlNoExtension"]) && System.Configuration.ConfigurationManager.AppSettings["friendlyUrlNoExtension"] == "1")
            if (PortalSettings.FriendlyUrlNoExtensionEnabled())
            {
                friendlyUrlNoExtension = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get pageId from pagename
        /// </summary>
        /// <returns>PageID</returns>
        public static string GetPageIDFromPageName(string pagepath)
        {
            PagesDB DB       = new PagesDB();
            var     settings = PortalSettings.GetPortalSettingsbyPageID(Portal.PageID, Config.DefaultPortal);

            int portalID = 0;

            if (settings != null)
            {
                portalID = settings.PortalID;
            }

            DataTable dtPages = DB.GetPagesFlatTable(portalID);

            //When friendly URl applied and go to Home page from and sub pages
            if (pagepath.ToLower().Contains("default.aspx"))
            {
                string page_ID = "1";
                return(page_ID);
            }

            // Check requested page url contains the /site when friendly URL is on
            var handlerFlag = System.Configuration.ConfigurationManager.AppSettings["handlerFlag"];

            if (pagepath.Contains("/" + handlerFlag + "/"))
            {
                string[] splitpaths       = pagepath.Split('/');
                int      index            = Array.IndexOf(splitpaths, handlerFlag);
                int      requesetedPageId = Convert.ToInt32(splitpaths[index + 1]);
                pagepath = HttpUrlBuilder.BuildUrl(requesetedPageId);
            }
            string _friendlyUrlExtension   = ".aspx";
            bool   _friendlyUrlNoExtension = false;

            if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["FriendlyUrlExtension"]))
            {
                _friendlyUrlExtension = System.Configuration.ConfigurationManager.AppSettings["FriendlyUrlExtension"];
            }

            //if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["friendlyUrlNoExtension"]) && System.Configuration.ConfigurationManager.AppSettings["friendlyUrlNoExtension"] == "1")
            if (PortalSettings.FriendlyUrlNoExtensionEnabled())
            {
                _friendlyUrlNoExtension = true;
            }

            pagepath = pagepath.ToLower();
            if (!pagepath.Contains(_friendlyUrlExtension) && !_friendlyUrlNoExtension)
            {
                pagepath += _friendlyUrlExtension;
            }

            if (pagepath.Contains(_friendlyUrlExtension) && _friendlyUrlNoExtension)
            {
                pagepath = pagepath.Replace(_friendlyUrlExtension, string.Empty);
            }

            foreach (DataRow pageRow in dtPages.Rows)
            {
                int    pageId = Convert.ToInt32(pageRow["PageID"]);
                string url    = HttpUrlBuilder.BuildUrl(pageId).ToLower();
                if (url == pagepath)
                {
                    return(pageId.ToString());
                }
                else
                {
                    if (!url.Contains(_friendlyUrlExtension))
                    {
                        url += _friendlyUrlExtension;
                    }
                    if (url == pagepath)
                    {
                        return(pageId.ToString());
                    }
                }
            }

            string dynamicPage = DB.GetDynamicPageUrl(pagepath);

            if (!string.IsNullOrEmpty(dynamicPage))
            {
                //-1 for dynamic pages
                return("-1");
            }

            // if page is not found it will throw 404 error
            throw new HttpException(404, "Page not Found", 3);
        }
Exemplo n.º 3
0
        /// <summary>
        /// The initialize method lets you retrieve provider specific settings from web.config
        /// </summary>
        /// <param name="name"></param>
        /// <param name="configValue"></param>
        public override void Initialize(string name, NameValueCollection configValue)
        {
            base.Initialize(name, configValue);

            // For legacy support first check provider settings then web.config/Appleseed.config legacy settings
            if (configValue["handlersplitter"] != null)
            {
                _defaultSplitter = configValue["handlersplitter"].ToString();
            }
            else
            {
                if (ConfigurationManager.AppSettings["HandlerDefaultSplitter"] != null)
                {
                    _defaultSplitter = ConfigurationManager.AppSettings["HandlerDefaultSplitter"];
                }
            }

            // For legacy support first check provider settings then web.config/Appleseed.config legacy settings
            if (configValue["handlerflag"] != null)
            {
                _handlerFlag = configValue["handlerflag"].ToString();
            }
            else
            {
                _handlerFlag = string.Empty;
            }

            //if (configValue["FriendlyUrlExtension"] != null)
            if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["FriendlyUrlExtension"]))
            {
                _friendlyUrlExtension = System.Configuration.ConfigurationManager.AppSettings["FriendlyUrlExtension"];
            }
            else
            {
                _friendlyUrlExtension = ".aspx";
            }

            //if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["friendlyUrlNoExtension"]) && System.Configuration.ConfigurationManager.AppSettings["friendlyUrlNoExtension"] == "1")
            if (PortalSettings.FriendlyUrlNoExtensionEnabled())
            {
                _friendlyUrlNoExtension = true;
            }

            // For legacy support first check provider settings then web.config/Appleseed.config legacy settings
            if (configValue["aliasinurl"] != null)
            {
                _aliasInUrl = bool.Parse(configValue["aliasinurl"].ToString());
            }
            else
            {
                if (ConfigurationManager.AppSettings["UseAlias"] != null)
                {
                    _aliasInUrl = bool.Parse(ConfigurationManager.AppSettings["UseAlias"]);
                }
            }

            // For legacy support first check provider settings then web.config/Appleseed.config legacy settings
            if (configValue["langinurl"] != null)
            {
                _langInUrl = bool.Parse(configValue["langinurl"].ToString());
            }
            else
            {
                if (ConfigurationManager.AppSettings["LangInURL"] != null)
                {
                    _langInUrl = bool.Parse(ConfigurationManager.AppSettings["LangInURL"]);
                }
            }

            if (configValue["ignoretargetpage"] != null)
            {
                _ignoreTargetPage = configValue["ignoretargetpage"].ToString();
            }

            if (configValue["cacheminutes"] != null)
            {
                _cacheMinutes = Convert.ToDouble(configValue["cacheminutes"].ToString());
            }

            if (configValue["pageidnosplitter"] != null)
            {
                _pageidNoSplitter = bool.Parse(configValue["pageidnosplitter"].ToString());
            }
            else
            {
                if (ConfigurationManager.AppSettings["PageIdNoSplitter"] != null)
                {
                    _pageidNoSplitter = bool.Parse(ConfigurationManager.AppSettings["PageIdNoSplitter"]);
                }
            }

            // For legacy support first check provider settings then web.config/Appleseed.config legacy settings
            if (configValue["friendlypagename"] != null)
            {
                // TODO: Friendly url's need to be fixed
                _friendlyPageName = configValue["friendlypagename"].ToString();
            }
            else
            {
                if (ConfigurationManager.AppSettings["FriendlyPageName"] != null)
                {
                    _friendlyPageName = ConfigurationManager.AppSettings["FriendlyPageName"];
                }
            }
            if (configValue["Querylist"] != null)
            {
                queryList = new StringDictionary();
                string list  = configValue["Querylist"].ToString();
                var    parts = list.Split(';');
                for (int i = 0; i < parts.Length; i++)
                {
                    queryList.Add(parts[i], parts[i]);
                }
            }
            if (configValue["ShowHieranchy"] != null)
            {
                string ShowHieranchy = configValue["ShowHieranchy"].ToString();
                try
                {
                    Hieranchy = bool.Parse(ShowHieranchy);
                }
                catch (Exception)
                {
                    Hieranchy = false;
                }
            }
        }