當前位置: 首頁>>代碼示例>>C#>>正文


C# RouteData.ApplyCurrentPage方法代碼示例

本文整理匯總了C#中System.Web.Routing.RouteData.ApplyCurrentPage方法的典型用法代碼示例。如果您正苦於以下問題:C# RouteData.ApplyCurrentPage方法的具體用法?C# RouteData.ApplyCurrentPage怎麽用?C# RouteData.ApplyCurrentPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.Routing.RouteData的用法示例。


在下文中一共展示了RouteData.ApplyCurrentPage方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetRouteData

        /// <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;
        }
開發者ID:sriv,項目名稱:BrickPile,代碼行數:29,代碼來源:UIRoute.cs

示例2: GetRouteData

        /// <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;
        }
開發者ID:sriv,項目名稱:BrickPile,代碼行數:36,代碼來源:PageRoute.cs

示例3: GetRouteData

        /// <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;
        }
開發者ID:stemyers,項目名稱:BrickPile,代碼行數:34,代碼來源:UIRoute.cs

示例4: GetRouteData

        /// <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;
        }
開發者ID:stemyers,項目名稱:BrickPile,代碼行數:34,代碼來源:PageRoute.cs

示例5: GetRouteData

        /// <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;
        }
開發者ID:bbqchickenrobot,項目名稱:brickpile,代碼行數:37,代碼來源:UIRoute.cs


注:本文中的System.Web.Routing.RouteData.ApplyCurrentPage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。