当前位置: 首页>>代码示例>>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;未经允许,请勿转载。