コード例 #1
0
        private static IHttpAction GetIIS5SVCRequestAction(IHttpActionFactory factory, PortalContext portalContext, NodeHead contextNode)
        {
            // Rewrite path (create PathInfo) if service called on IIS5
            var       httpContext             = portalContext.OwnerHttpContext;
            const int XP_MAJOR_VERSION_NUMBER = 5;

            if (httpContext.Request.Path.Contains(".svc") && Environment.OSVersion.Version.Major == XP_MAJOR_VERSION_NUMBER)
            {
                string filePath, pathInfo, queryString;
                string originalPath = httpContext.Request.Path;

                string[] uriElements = System.Text.RegularExpressions.Regex.Split(originalPath, @".svc/");

                filePath = uriElements[0];
                if (!filePath.EndsWith(".svc", StringComparison.InvariantCultureIgnoreCase))
                {
                    filePath = string.Concat(filePath, ".svc");
                }

                pathInfo = uriElements.Length > 1 ? uriElements[1] : String.Empty;
                string qs = httpContext.Request.Url.Query;
                queryString = string.IsNullOrEmpty(qs) ? string.Empty : qs.Substring(1);

                httpContext.RewritePath(filePath, pathInfo, queryString);

                return(factory.CreateRewriteAction(portalContext, contextNode, null, filePath, pathInfo, queryString));
            }
            return(null);
        }
コード例 #2
0
 private static IHttpAction GetDefaultContextAction(IHttpActionFactory factory, PortalContext portalContext, NodeHead contextNode, string actionName, string appNodePath)
 {
     if (String.IsNullOrEmpty(actionName) && String.IsNullOrEmpty(appNodePath))
     {
         if (!String.IsNullOrEmpty(portalContext.QueryStringNodePropertyName))
         {
             return(factory.CreateDownloadAction(portalContext, contextNode, null, GetRewritePath(contextNode, portalContext), portalContext.QueryStringNodePropertyName));
         }
         var nodeType = contextNode.GetNodeType();
         if (nodeType.IsInstaceOfOrDerivedFrom("Page"))
         {
             return(factory.CreateRewriteAction(portalContext, contextNode, null, GetRewritePath(contextNode, portalContext)));
         }
         if (nodeType.IsInstaceOfOrDerivedFrom("File"))
         {
             return(factory.CreateDownloadAction(portalContext, contextNode, null, GetRewritePath(contextNode, portalContext), PortalContext.DefaultNodePropertyName));
         }
     }
     return(null);
 }
コード例 #3
0
 private static IHttpAction GetDefaultContextAction(IHttpActionFactory factory, PortalContext portalContext, NodeHead contextNode, string actionName, string appNodePath)
 {
     if (String.IsNullOrEmpty(actionName) && String.IsNullOrEmpty(appNodePath))
     {
         if(!String.IsNullOrEmpty(portalContext.QueryStringNodePropertyName))
             return factory.CreateDownloadAction(portalContext, contextNode, null, GetRewritePath(contextNode, portalContext), portalContext.QueryStringNodePropertyName);
         var nodeType = contextNode.GetNodeType();
         if (nodeType.IsInstaceOfOrDerivedFrom("Page"))
             return factory.CreateRewriteAction(portalContext, contextNode, null, GetRewritePath(contextNode, portalContext));
         if (nodeType.IsInstaceOfOrDerivedFrom("File"))
             return factory.CreateDownloadAction(portalContext, contextNode, null, GetRewritePath(contextNode, portalContext), PortalContext.DefaultNodePropertyName);
     }
     return null;
 }
コード例 #4
0
        private static IHttpAction GetIIS5SVCRequestAction(IHttpActionFactory factory, PortalContext portalContext, NodeHead contextNode)
        {
            // Rewrite path (create PathInfo) if service called on IIS5
            var httpContext = portalContext.OwnerHttpContext;
            const int XP_MAJOR_VERSION_NUMBER = 5;
            if (httpContext.Request.Path.Contains(".svc") && Environment.OSVersion.Version.Major == XP_MAJOR_VERSION_NUMBER)
            {
                string filePath, pathInfo, queryString;
                string originalPath = httpContext.Request.Path;

                string[] uriElements = System.Text.RegularExpressions.Regex.Split(originalPath, @".svc/");

                filePath = uriElements[0];
                if (!filePath.EndsWith(".svc", StringComparison.InvariantCultureIgnoreCase))
                    filePath = string.Concat(filePath, ".svc");

                pathInfo = uriElements.Length > 1 ? uriElements[1] : String.Empty;
                string qs = httpContext.Request.Url.Query;
                queryString = string.IsNullOrEmpty(qs) ? string.Empty : qs.Substring(1);

                httpContext.RewritePath(filePath, pathInfo, queryString);

                return factory.CreateRewriteAction(portalContext, contextNode, null, filePath, pathInfo, queryString);
            }
            return null;
        }