Try our conversational search powered by Generative AI!

Eventhandler to IContentRouteEvents.RoutedContent should be able RewritePath

Found in

EPiServer.CMS.Core 11.5.4

Fixed in

EPiServer.CMS.Core 11.7.1

(Or a related package)

Created

May 03, 2018

Updated

May 16, 2018

Area

CMS Core

State

Closed, Fixed and tested


Description

DefaultContentRoute should return RoutedEventArgs.RoutingSegmentContext.RouteData to make it possible for an eventhandler to continue routing to other routes.

For example, if I have a route handler as:

private void RoutedContent(object sender, RoutingEventArgs e)
        {
            var context = _httpContextAccessor();
            var request = context?.Request;
            if (request != null && request.AcceptTypes.Contains(RoutingConstants.JsonContentType))
            {
                e.RoutingSegmentContext.RouteData = null;
                context.RewritePath($"/{EPiServer.ContentApi.RouteConstants.BaseContentApiRoute}content/{e.RoutingSegmentContext.RoutedContentLink}");
            }
        }

It would be great if it could continue to route to the web api controller. Currently, it returns the content routed to, regardless of the rewrite.