November Happy Hour will be moved to Thursday December 5th.

CustomContentApiRoutingEventHandler namespace not found

Vote:
 

Hi!

In this example, https://world.episerver.com/documentation/developer-guides/content-delivery-api/content-delivery-api-and-episerver-forms/ there is a reference to CustomContentApiRoutingEventHandler and we have added these namespaces:

  • EPiServer.ContentApi.Cms
  • EPiServer.ContentApi.Core.Configuration 
  • EPiServer.ContentApi.Routing

and it is still missing... 

Anyone got a clue?

#227878
Sep 15, 2020 12:24
Vote:
 

Hi Fredrik,

The CustomContentApiRoutingEventHandler is not part of the given namespaces or EPiServer.ContentDeliveryApi. You have to create a class and need to write your logic like below:

    /// <summary>
    /// Custom routing event handler for Music Festival.    
    /// </summary>
    public class CustomContentApiRoutingEventHandler : RoutingEventHandler
    {
        public CustomContentApiRoutingEventHandler(
            IContentRouteEvents routeEvents,
            ServiceAccessor<HttpContextBase> httpContextAccessor,
            ContentApiRouteService contentApiRouteService)
            : base(routeEvents, httpContextAccessor, contentApiRouteService)
        {            
        }

        // If language does not exists in the routing context, we return ContentLanguage.PreferredCulture as default language
        protected override string GetLanguage(SegmentContext routingContext, HttpRequestBase request)
        {
            var language = routingContext.Language ?? routingContext.ContentLanguage ?? ContentLanguage.PreferredCulture.Name;
            
            return language;
        }       
    }
#227906
Edited, Sep 16, 2020 4:47
Vote:
 

Thank you, I will try and see if this will help. 

#227912
Sep 16, 2020 8:22
* 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.