Changes in simple address routing
In package EPiServer.CMS.Core.7.13.3 we have solved an issue that causes a slightly different behaviour in how simple addresses are routed. As a background: for “ordinary” content routing we introduced a more strict handling in 7.5 where for example it was not possible to have a language segment specifying one language while the segment it self was on a content instance on another language. Like for example:
http://mysite/en/produkter (where “produkter” is the segment on the swedish version)
In CMS 7 that was possible to route and resulted in the english version of the page. In CMS 7.5 that results in a 404. We also introduced a configuration setting strictLanguageRouting that can be set to false to get the more tolerant behaviour as in CMS 7.
Now we have also changed simple address routing so it is more strict. So given that a page exist in both language "en" and language "sv" and has simple addresses "ensimple" and "svsimple" the following scenarios apply. For those scenarios that differs from previous version a parenthesis is added describing the old behaviour:
No host language mapping, strictLanguageRouting=true
-
http://sitehost/ensimple => english page
-
http://sitehost/svsimple => swedish page
-
http://sitehost/en/ensimple => english page
-
http://sitehost/sv/svsimple => swedish page
-
http://sitehost/sv/ensimple => 404 (this gave swedish page in previous version)
No host language mapping, strictLanguageRouting=false
-
http://sitehost/ensimple => english page
-
http://sitehost/svsimple => swedish page
-
http://sitehost/en/ensimple => english page
-
http://sitehost/sv/svsimple => swedish page
-
http://sitehost/sv/ensimple => swedish page
Host "sitehost" mapped to language "en", strictLanguageRouting=true
-
http://sitehost/ensimple => english page
-
http://sitehost/svsimple => 404 (this gave english page in previous version)
-
http://sitehost/en/ensimple => 404 (this gave english page in previous version)
-
http://sitehost/sv/svsimple => swedish page
-
http://sitehost/sv/ensimple => 404 (this gave swedish page in previous version)
Host "sitehost" mapped to language "en", strictLanguageRouting=false
-
http://sitehost/ensimple => english page
-
http://sitehost/svsimple => swedish page
-
http://sitehost/en/ensimple => english page
-
http://sitehost/sv/svsimple => swedish page
-
http://sitehost/sv/ensimple => swedish page
To get the more tolerant behaviour as in previous versions you can either set the strictLanguageRouting attribute (on configuration element applicationSettings) to false. That will however not only affect simple address but also "ordinary" routing so it works as in EPiServer 7. To only affect simple address you could have an initialization module that configures simple address routing to not use strict language routing as the following code:
using EPiServer.Framework;
using EPiServer.Web.Routing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcPreview
{
[InitializableModule]
public class SimpleAddressModule : IInitializableModule
{
public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
EPiServer.Global.RoutesRegistered += delegate(object source, RouteRegistrationEventArgs args)
{
var simpleAddressRoute = args.Routes.OfType<ContentRoute>().FirstOrDefault(r => r.Name.Equals("simpleaddress"));
if (simpleAddressRoute != null)
{
simpleAddressRoute.StrictLanguageRoutingResolver = () => false;
}
};
}
public void Preload(string[] parameters)
{
}
public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
}
}
}
Comments