Optional action segment in route - context.RoutedContentLink is SysRoot

Vote:
 

Hi, 

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)
        {
            base.RegisterRoutes(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);

                routes.MapContentRoute(
                    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
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.