/// <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); } foreach (DataRow pageRow in dtPages.Rows) { int pageId = Convert.ToInt32(pageRow["PageID"]); string url = HttpUrlBuilder.BuildUrl(pageId); if (url.ToLower() == pagepath.ToLower()) { 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); }