Ejemplo n.º 1
0
        /// <summary>
        /// Returns information about the requested route.
        /// </summary>
        /// <param name="httpContext">An object that encapsulates information about the HTTP request.</param>
        /// <returns>
        /// An object that contains the values from the route definition.
        /// </returns>
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            // get the virtual path of the request
            var virtualPath = httpContext.Request.CurrentExecutionFilePath;

            var routeData = new RouteData(this, _routeHandler);

            foreach (var defaultPair in this._defaults)
                routeData.Values[defaultPair.Key] = defaultPair.Value;

            // try to resolve the current item
            var pathData = PathResolver.ResolvePath(routeData, virtualPath.Replace("/ui/pages", string.Empty));

            // Abort and proceed to other routes in the route table
            if (pathData == null) {
                return null;
            }

            routeData.ApplyCurrentPage(DefaultControllerName, pathData.Action, pathData.CurrentPage);

            return routeData;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the route data.
        /// </summary>
        /// <param name="httpContextBase">The HTTP context base.</param>
        /// <returns></returns>
        public override RouteData GetRouteData(HttpContextBase httpContextBase)
        {
            var routeData = new RouteData(this, _routeHandler);

            // get the virtual path of the request
            var virtualPath = httpContextBase.Request.CurrentExecutionFilePath.TrimStart(new[] { '/' });

            // try to resolve the current item
            var pathData = this.PathResolver.ResolvePath(routeData, virtualPath);

            // Abort and proceed to other routes in the route table
            if (pathData == null) {
                return null;
            }

            // throw a proper 404 if the page is not published or if it's deleted
            if((!pathData.CurrentPage.Metadata.IsPublished || pathData.CurrentPage.Metadata.IsDeleted) && !httpContextBase.User.Identity.IsAuthenticated ) {
                throw new HttpException(404, "HTTP/1.1 404 Not Found");
            }

            routeData.ApplyCurrentPage(pathData.Controller, pathData.Action, pathData.CurrentPage);
            routeData.ApplyCurrentStructureInfo(new StructureInfo
            {
                NavigationContext = httpContextBase.User.Identity.IsAuthenticated ? pathData.NavigationContext.OrderBy(x => x.Metadata.SortOrder) : pathData.NavigationContext.Where(x => x.Metadata.IsPublished).Where(x => !x.Metadata.IsDeleted).OrderBy(x => x.Metadata.SortOrder),
                CurrentPage = pathData.CurrentPage,
                StartPage = pathData.NavigationContext.Single(x => x.Parent == null),
                ParentPage = pathData.CurrentPage.Parent != null ? pathData.NavigationContext.SingleOrDefault(x => x.Id == pathData.CurrentPage.Parent.Id) : null
            });

            return routeData;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns information about the requested route.
        /// </summary>
        /// <param name="httpContext">An object that encapsulates information about the HTTP request.</param>
        /// <returns>
        /// An object that contains the values from the route definition.
        /// </returns>
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            // get the virtual path of the request
            var virtualPath = httpContext.Request.CurrentExecutionFilePath;

            // exit with the base functionality
            if (!virtualPath.StartsWith(PagesUrlPattern, StringComparison.OrdinalIgnoreCase)) {
                return null;
            }

            var routeData = new RouteData(this, _routeHandler);

            foreach (var defaultPair in this._defaults)
                routeData.Values[defaultPair.Key] = defaultPair.Value;

            // try to resolve the current item
            var pathData = PathResolver.ResolvePath(routeData, virtualPath.Replace(PagesUrlPattern, string.Empty));

            // Abort and proceed to other routes in the route table
            if (pathData == null) {
                return null;
            }

            routeData.ApplyCurrentPage(DefaultControllerName, pathData.Action, pathData.CurrentPage);

            return routeData;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the route data.
        /// </summary>
        /// <param name="httpContextBase">The HTTP context base.</param>
        /// <returns></returns>
        public override RouteData GetRouteData(HttpContextBase httpContextBase)
        {
            if (httpContextBase.Request.Url != null && new Regex("^https?://" + SubDomain).IsMatch(httpContextBase.Request.Url.AbsoluteUri)) {
                return null;
            }

            var routeData = new RouteData(this, _routeHandler);

            // get the virtual path of the request
            var virtualPath = httpContextBase.Request.CurrentExecutionFilePath.TrimStart(new[] { '/' });

            // try to resolve the current item
            var pathData = this.PathResolver.ResolvePath(routeData, virtualPath);

            // Abort and proceed to other routes in the route table
            if (pathData == null) {
                return null;
            }

            // throw a proper 404 if the page is not published or if it's deleted
            if(!pathData.CurrentPage.Metadata.IsPublished || pathData.CurrentPage.Metadata.IsDeleted) {
                throw new HttpException(404, "HTTP/1.1 404 Not Found");
            }

            routeData.ApplyCurrentPage(pathData.Controller, pathData.Action, pathData.CurrentPage);
            routeData.ApplyCurrentStructureInfo(new StructureInfo { Pages = pathData.Pages, StartPage = pathData.Pages.Where(x => x.Parent == null) as IPageModel});

            return routeData;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns information about the requested route.
        /// </summary>
        /// <param name="httpContext">An object that encapsulates information about the HTTP request.</param>
        /// <returns>
        /// An object that contains the values from the route definition.
        /// </returns>
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            // get the virtual path of the request
            var virtualPath = httpContext.Request.CurrentExecutionFilePath;

            var routeData = new RouteData(this, _routeHandler);

            foreach (var defaultPair in this._defaults)
                routeData.Values[defaultPair.Key] = defaultPair.Value;

            // try to resolve the current item
            var pathData = PathResolver.ResolvePath(routeData, virtualPath.Replace("/ui/pages", string.Empty));

            // Abort and proceed to other routes in the route table
            if (pathData == null) {
                return null;
            }

            routeData.ApplyCurrentPage(DefaultControllerName, pathData.Action, pathData.CurrentPage);
            routeData.ApplyCurrentContent(pathData.CurrentContent);
            routeData.ApplyCurrentStructureInfo(new StructureInfo
            {
                NavigationContext = pathData.NavigationContext.OrderBy(x => x.Metadata.SortOrder),
                CurrentPage = pathData.CurrentPage,
                CurrentContent = pathData.CurrentContent,
                StartPage = pathData.NavigationContext.Single(x => x.Parent == null),
                ParentPage = pathData.CurrentPage.Parent != null ? pathData.NavigationContext.SingleOrDefault(x => x.Id == pathData.CurrentPage.Parent.Id) : null
            });
            return routeData;
        }