Optional action segment in route - context.RoutedContentLink is SysRoot

Member since: 2010


I've been using this code to exclude default action segment and registering it from Global.asax like this.

This does not seem to work in 7.5 any longer, but nothing in Johan's post suggests so. 

The problem is that context.RoutedContentLink is always SysRoot and not the page I am currently accessing (in EPi 7.1, this is not the case).

However, there has been a change in how DefaultUrlSegmentRouter is instantiated, so my Global.asax looks like this now:

        protected override void RegisterRoutes(RouteCollection routes)

            IContentLoader contentLoader;
            ServiceLocator.Current.TryGetExistingInstance(out contentLoader);

            var urlSegmentRouter = DefaultUrlSegmentRouter.Create(ServiceLocator.Current);

            if (contentLoader != null && urlSegmentRouter != null)
                var segment = new OptionalActionSegment("action", contentLoader);
                var routingParameters = new MapContentRouteParameters
                    SegmentMappings = new Dictionary<string, ISegment>(),
                    UrlSegmentRouter = urlSegmentRouter

                routingParameters.SegmentMappings.Add("action", segment);

                    name: "optionalaction",
                    url: "{language}/{node}/{partial}/{action}/{anchorOnPage}",
                    defaults: new { action = "Index" },
                    parameters: routingParameters);

Am I missing something here or is there a bug?

#82942 Mar 21, 2014 15:33