Ejemplo n.º 1
0
        public override RouteData GetRouteData(System.Web.HttpContextBase httpContext)
        {
            //如果HttpHandler为NULL,则不处理
            if (httpContext.Handler != null)
            {
                return(null);
            }
            //请求Url的绝对路径
            string filePath = httpContext.Request.Url.AbsolutePath;

            if (filePath.IsEmpty())
            {
                return(null);
            }
            filePath = filePath.ToLower();
            var endPage = filePath.RightOfRightmostOf('/');

            if (endPage.IsNotEmpty() && endPage.Contains("?"))
            {
                endPage = endPage.Split('?')[0];
            }
            var routeWebHander = GlobalApplicationObject.Current.ApplicationContext.RoutingManager.RouteWebHandlerInfoList.FirstOrDefault(p => p.routeUrl == filePath);

            if (routeWebHander.IsNotNull())
            {
                var routeHandler = new RouteHandler()
                {
                    RouteWebHandlerInfo = routeWebHander
                };
                var data = new RouteData(this, routeHandler);
                return(data);
            }
            return(null);
        }
Ejemplo n.º 2
0
 public override RouteData GetRouteData(System.Web.HttpContextBase httpContext)
 {
     //如果HttpHandler为NULL,则不处理
     if (httpContext.Handler != null) return null;
     //请求Url的绝对路径
     string filePath = httpContext.Request.Url.AbsolutePath;
     if (filePath.IsEmpty()) return null;
     filePath = filePath.ToLower();
     var endPage = filePath.RightOfRightmostOf('/');
     if (endPage.IsNotEmpty() && endPage.Contains("?"))
         endPage = endPage.Split('?')[0];
     var routeWebHander = GlobalApplicationObject.Current.ApplicationContext.RoutingManager.RouteWebHandlerInfoList.FirstOrDefault(p => p.routeUrl == filePath);
     if (routeWebHander.IsNotNull())
     {
         var routeHandler = new RouteHandler()
         {
             RouteWebHandlerInfo = routeWebHander
         };
         var data = new RouteData(this, routeHandler);
         return data;
     }
     return null;
 }