GetLookupTable() public static method

Get the lookup table for quick lookups
public static GetLookupTable ( ) : Redirect>.Dictionary
return Redirect>.Dictionary
        public bool TryFindContent(PublishedContentRequest request)
        {
            //Get the requested URL path + query
            var path     = request.Uri.PathAndQuery.ToLower();
            var fullpath = request.Uri.OriginalString.ToLower();

            //Check the table
            var redirectLookupTable = RedirectRepository.GetLookupTable();

            Redirect matchedRedirect;

            if (redirectLookupTable.TryGetValue(path, out matchedRedirect))
            {
                // set the 301 redirect on the request and return
                request.SetRedirectPermanent(matchedRedirect.NewUrl);
                return(true);
            }

            if (redirectLookupTable.TryGetValue(fullpath, out matchedRedirect))
            {
                // set the 301 redirect on the request and return
                request.SetRedirectPermanent(matchedRedirect.NewUrl);
                return(true);
            }


            //did not found one
            return(false);
        }
Esempio n. 2
0
        public bool TryFindContent(PublishedContentRequest request)
        {
            //Get the requested URL path + query
            var path = request.Uri.PathAndQuery.ToLower();

            //Check the table
            var redirectLookupTable = RedirectRepository.GetLookupTable();
            var matchedRedirect     = redirectLookupTable.ContainsKey(path) ? redirectLookupTable[path] : null;

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

            //Found one, set the 301 redirect on the request and return
            request.SetRedirectPermanent(matchedRedirect.NewUrl);
            return(true);
        }