Example #1
0
        /// <summary>
        /// Called in the HTTP pipeline chain of execution when ASP.NET responds to a request.
        /// </summary>
        /// <param name="context">HTTP context.</param>
        public async Task Invoke(HttpContext context)
        {
            // Get root URL (e.g. "http://mydomain.com")
            string rootUrl = _webHelperService.GetRootUrl();

            // Lookup domain details for this URL
            Domain domain = _domainService.ReadByUrl(rootUrl);
            Web    web    = _webService.Read(domain.TenantId);

            // Save domain details where they can be looked up throughtout the lifecycle of the HTTP request
            _webHelperService.SetItem <Domain>("RiversideCmsDomain", domain);
            _webHelperService.SetItem <Web>("RiversideCmsWeb", web);

            // Redirect if a redirect URL specified, otherwise invoke next action
            if (domain.RedirectUrl != null)
            {
                _webHelperService.Redirect(domain.RedirectUrl);
            }
            else
            {
                await _next.Invoke(context);
            }
        }
        /// <summary>
        /// Retrieves list of navigation breadcrumbs for the specified breadcrumb collection.
        /// </summary>
        /// <param name="breadcrumbsId">Identifies the breadcrumbs collection that is returned.</param>
        /// <returns>Breadcrumb navigation.</returns>
        public List <Breadcrumb> GetBreadcrumbs(string breadcrumbsId)
        {
            // Get dictionary containing lists of breadcumbs
            string key = _controlConfigurationService.GetBreadcrumbsKey();
            Dictionary <string, List <Breadcrumb> > breadcrumbsDict = _webHelperService.GetItem <Dictionary <string, List <Breadcrumb> > >(key);

            if (breadcrumbsDict == null)
            {
                breadcrumbsDict = new Dictionary <string, List <Breadcrumb> >();
                _webHelperService.SetItem <Dictionary <string, List <Breadcrumb> > >(key, breadcrumbsDict);
            }

            // Get list of breadcrumbs for the specified id
            if (!breadcrumbsDict.ContainsKey(breadcrumbsId))
            {
                breadcrumbsDict.Add(breadcrumbsId, new List <Breadcrumb>());
            }
            return(breadcrumbsDict[breadcrumbsId]);
        }