public IEnumerable <RouteMatchInfo> GetRouteMatches() { HttpContextBase contextBase = new ContextMapper((string)Context.Items["routePath"]); foreach (RouteBase rbase in RouteTable.Routes) { Route route = rbase as Route; RouteData rData = route.GetRouteData(contextBase); if (rData != null) { StringBuilder sb = new StringBuilder(); foreach (string key in rData.Values.Keys) { sb.AppendFormat("{0} = {1},", key, rData.Values[key]); } yield return(new RouteMatchInfo { matches = true, path = route.Url, values = sb.ToString() }); } else { yield return(new RouteMatchInfo { matches = false, path = route.Url, values = "-" }); } } }
public IEnumerable <RouteMatchInfo> GetRouteMatches() { HttpContextBase contextBase = new ContextMapper((string)Context.Items["routePath"], Request); foreach (RouteBase route in RouteTable.Routes.Where(route => route != null)) { RouteData rData = route.GetRouteData(contextBase); if (rData != null) { var builder = new StringBuilder(); foreach (var key in rData.Values.Keys) { builder.AppendFormat("{0} = {1},", key, rData.Values[key]); } yield return(new RouteMatchInfo { Matches = true, Path = route is Route ? ((Route)route).Url : route.GetType().ToString(), Values = builder.ToString() }); } else { yield return(new RouteMatchInfo { Matches = false, Path = route is Route ? ((Route)route).Url : route.GetType().ToString(), Values = "-" }); } } }