public static PageUrlOptions ParsePublicUrl(string url, out NameValueCollection notUsedQueryParameters)
        {
            var urlString = new UrlString(url);

            notUsedQueryParameters = null;
            if (!IsPublicUrl(urlString.FilePath))
            {
                return(null);
            }

            string requestPath;
            Uri    uri;

            if (Uri.TryCreate(urlString.FilePath, UriKind.Absolute, out uri))
            {
                requestPath = HttpUtility.UrlDecode(uri.AbsolutePath).ToLower();
            }
            else
            {
                requestPath = urlString.FilePath.ToLower();
            }

            string      requestPathWithoutUrlMappingName;
            CultureInfo locale = PageUrl.GetCultureInfo(requestPath, out requestPathWithoutUrlMappingName);

            if (locale == null)
            {
                return(null);
            }

            string dataScopeName = urlString["dataScope"];

            if (dataScopeName.IsNullOrEmpty())
            {
                dataScopeName = DataScopeIdentifier.GetDefault().Name;
            }

            Guid pageId = Guid.Empty;

            using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), locale))
            {
                if (PageStructureInfo.GetLowerCaseUrlToIdLookup().TryGetValue(requestPath.ToLower(), out pageId) == false)
                {
                    return(null);
                }
            }

            urlString["dataScope"] = null;

            notUsedQueryParameters = urlString.GetQueryParameters();

            return(new PageUrlOptions(dataScopeName, locale, pageId, UrlType.Public));
        }
        public static bool TryParseFriendlyUrl(string relativeUrl, out PageUrlOptions urlOptions)
        {
            if (IsAdminPath(relativeUrl))
            {
                urlOptions = null;
                return(false);
            }

            string      path;
            CultureInfo cultureInfo = PageUrl.GetCultureInfo(relativeUrl, out path);

            if (cultureInfo == null)
            {
                urlOptions = null;
                return(false);
            }

            string loweredRelativeUrl = relativeUrl.ToLower(CultureInfo.InvariantCulture);

            // Getting the site map
            IEnumerable <XElement> siteMap;
            DataScopeIdentifier    dataScope = DataScopeIdentifier.GetDefault();

            using (new DataScope(dataScope, cultureInfo))
            {
                siteMap = PageStructureInfo.GetSiteMap();
            }

            XAttribute matchingAttributeNode = siteMap.DescendantsAndSelf()
                                               .Attributes("FriendlyUrl")
                                               .FirstOrDefault(f => string.Equals(f.Value, loweredRelativeUrl, StringComparison.OrdinalIgnoreCase));

            if (matchingAttributeNode == null)
            {
                urlOptions = null;
                return(false);
            }

            XElement pageNode = matchingAttributeNode.Parent;

            XAttribute pageIdAttr = pageNode.Attributes("Id").FirstOrDefault();

            Verify.IsNotNull(pageIdAttr, "Failed to get 'Id' attribute from the site map");
            Guid pageId = new Guid(pageIdAttr.Value);

            urlOptions = new PageUrlOptions(dataScope.Name, cultureInfo, pageId, UrlType.Friendly);
            return(true);
        }
 public static CultureInfo GetCultureInfo(string requestPath, out string requestPathWithoutUrlMappingName)
 {
     return(PageUrl.GetCultureInfo(requestPath, out requestPathWithoutUrlMappingName));
 }
        public static CultureInfo GetCultureInfo(string requestPath)
        {
            string newRequestPath;

            return(PageUrl.GetCultureInfo(requestPath, out newRequestPath));
        }