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


C# HttpContextBase.GetPortalContext方法代碼示例

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


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

示例1: GetRouteData

        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            PortalRequestContext context = httpContext.GetPortalContext();
            if(context.ActivePage != null) {
                return null;
            }

            string pagePath = httpContext.Request.AppRelativeCurrentExecutionFilePath;

            // Normalize path to the form: /Segment/Segment/Segment
            pagePath = NormalizePagePath(pagePath);

            // Search for the page
            Page page = PageRepository.GetLongestPrefixMatch(pagePath);

            // If there is no matching page, return null
            if(page == null) {
                return null;
            }

            // Set the page in the context
            context.ActivePage = page;

            // Remove the actual page path and set as the new app-relative path
            string appRelativePath = pagePath.Substring(page.Path.Length);

            // Rewrite and reroute the request
            // TODO: Can HttpContext.RewritePath do what we need?  I do want to preserve the old HttpContext for use after routing
            HttpContextBase rewrittenContext = new RewrittenHttpContext(httpContext, appRelativePath);
            return RerouteRequest(r => r.GetRouteData(rewrittenContext));
        }
開發者ID:anurse,項目名稱:MaVeriCk,代碼行數:31,代碼來源:PagePrerouter.cs

示例2: GetRouteData

        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            PortalRequestContext portalRequestContext = httpContext.GetPortalContext();

            if(httpContext.HasPortalContext() && portalRequestContext.ActivePortal != null) {
                return null; // Portal has already been specified, bypass this pre-router
            }

            Uri requestUrl = httpContext.Request.Url;

            PortalPrefix prefix = PortalPrefixRepository.GetLongestPrefixMatch(requestUrl);

            if(prefix == null || prefix.Portal == null) {
                return null;
            }

            portalRequestContext.ActivePortal = prefix.Portal;
            portalRequestContext.ActivePortalPrefix = prefix;

            // Determine the Portal-relative url
            string portalRelativeUrl = ExtractPortalRelativeUrl(requestUrl, prefix);

            // Rewrite and re-route the request
            // TODO: Can HttpContext.RewritePath do what we need?  I do want to preserve the old HttpContext for use after routing
            HttpContextBase rewrittenContext = new RewrittenHttpContext(httpContext, portalRelativeUrl);
            return RerouteRequest(route => route.GetRouteData(rewrittenContext));
        }
開發者ID:anurse,項目名稱:MaVeriCk,代碼行數:27,代碼來源:PortalVirtualizationPrerouter.cs

示例3: SetActivePortalPrefix

 private static void SetActivePortalPrefix(HttpContextBase httpContext, string prefix)
 {
     httpContext.GetPortalContext().ActivePortalPrefix = new PortalPrefix {Id = 1, Prefix = prefix};
 }
開發者ID:anurse,項目名稱:MaVeriCk,代碼行數:4,代碼來源:PortalVirtualizationPrerouterTests.cs


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