SeoUriRouter is obsolete



In our project we have a class SimpleAddressRouteHandler which overrides SeoUriRouter to set custom market and language.

But after upgrading to Commerce v13, SeoUriRouter has become obsolete. What is the recommended way to replace SeoUriRouter? I can't find any information about it.

Thanks in advance!


 [ServiceConfiguration(ServiceType = typeof(ISimpleAddressRouteHandler), Lifecycle = ServiceInstanceScope.Singleton)]
    public class SimpleAddressRouteHandler : SeoUriRouter
        private static readonly ILogger _log = LogManager.GetLogger(typeof(SimpleAddressRouteHandler));
        private readonly IMarketService _marketService;
        private readonly ICurrentMarket _currentMarket;

        public SimpleAddressRouteHandler(PartialRouteHandler partialRouteHandler, IContentLoader contentLoader, ReferenceConverter referenceConverter, IContentVersionRepository contentVersionRepository, ICatalogSystem catalogSystem, IMarketService marketService, ICurrentMarket currentMarket) 
            : base(partialRouteHandler, contentLoader, referenceConverter, contentVersionRepository, catalogSystem)
            _marketService = marketService;
            _currentMarket = currentMarket;

        /// <summary>
		/// Tries to handle a segment value as a simple address.
		/// </summary>
		/// <param name="urlSegment">The simple address</param>
		/// <param name="routeRoot">The route root</param>
		/// <param name="segmentContext">The segment context</param>
		/// <returns><c><see cref="T:EPiServer.Web.Routing.Segments.SimpleAddressRouteValues" /></c> if <paramref name="urlSegment" /> was handled, otherwise <c>null</c></returns>
		public override SimpleAddressRouteValues GetRouteValues(string urlSegment, ContentReference routeRoot, SegmentContext segmentContext)
            SimpleAddressRouteHandler._log.DebugBeginMethod("GetRouteValues", new object[]
            //strip software part from the url again
            if (urlSegment.StartsWith("software/", StringComparison.InvariantCultureIgnoreCase)) 
                urlSegment = urlSegment.Substring("software/".Length);

            //strip software part from the url again
            if (urlSegment.StartsWith("trainingen/", StringComparison.InvariantCultureIgnoreCase))
                urlSegment = urlSegment.Substring("trainingen/".Length);
            ProcessLanguageAndMarketSegment(ref urlSegment, segmentContext);
            if (urlSegment == null) return null;
            return base.GetRouteValues(urlSegment, routeRoot, segmentContext);

        public void ProcessLanguageAndMarketSegment(ref string urlSegment, SegmentContext segmentContext)
            //Check LanguageMarket segment
            if (urlSegment.Contains("/"))
                var firstSegment = urlSegment.Split('/')[0]; //First index shouldbe our languageAndMarketSegment

                //Our segment is always {TwoLetterIsoCode}-{MarketCode}, therefor segment[2] should always be "-"
                if (firstSegment.Length >= 3 && firstSegment[2] == '-')
                    var segmentParts = firstSegment.Split('-');

                    //is the last part a valid marketCode
                    var languagePart = segmentParts[0];
                    var marketPart = segmentParts[1];

                    var validMarket = MarketConstants.UrlToMarketMappings.ContainsKey(marketPart);
                    if (validMarket)
                        //Set market
                        var marketCode = MarketConstants.UrlToMarketMappings[marketPart];
                        var marketId = new MarketId(marketCode);

                        //Set language
                        var market = _marketService.GetMarket(marketId);
                        var language = market.Languages.FirstOrDefault(x => x.TwoLetterISOLanguageName == languagePart);

                        if (language == null)
                            urlSegment = null;

                        segmentContext.Language = language.ToString();

                        //Finally strip language and market segment from url
                        urlSegment = urlSegment.Substring(urlSegment.IndexOf('/') + 1);
Jul 09, 2019 10:08

It is "replaced" by SeoAddressResolver. Note that it is note a direct replacement. 

Jul 09, 2019 11:55
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.