ContentRoute.GetValue Breaking Change in Episerver 10

  • Updated

This article describes an issue with ContentRoute.GetValue not being available after updating to Episerver 10.  The code recommends using the IContentRoute. however that API does not have direct access to GetValue.

Please see here for breaking changes in CMS 10.

Breaking changes
The following classes were removed from the public API and implementation moved into sub namespace ".Internal". In cases where an implementation was exposed in another public API, such as PageRouteHelper on PageController, the API was changed to expose IPageRouteHelper.

  • EPiServer.Web.Routing.ContentRoute
  • EPiServer.Web.Routing.ContentRouteHelper
  • EPiServer.Web.Routing.CrossSiteContentRouteContraint
  • ContentRoute -> IContentRoute
  • ContentRoute static events -> IContentRouteEvents
  • PageRouteHelper -> IPageRouteHelper
  • ContentRouteHelper -> IContentRouteHelper


Fix Version/s:
EPiServer.CMS.Core 10.0.1

The new ".Internal" namespaces

One of the bigger changes is that all APIs have been reviewed to find internal implementation classes and that those have been moved to internal namespaces. You can see exactly which APIs are affected in these stories: CMS-3762 (Episerver CMS Core) and CMS-3755 (Episerver CMS UI). Read more about these changes in Henrik Nyström's blog post.

It appears to be fixed into 10.0.1 for the new namespaces. 

In the case of ContentRoute specifically the original code would look like this.

var contentLink = ContentRoute.GetValue("node", requestContext, routeValues) as ContentReference;

The code after updating to Episerver 10 could look like this.

var contentLink = RequestContextExtension.GetRouteValue(requestContext, "node", routeValues) as ContentReference;