November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
The character map is not used during routing of a request request (that is it will not be used to e.g. map 'ä' to 'a' during segment parsing). It is used when an url segment is created. So e.g. given that you have a regexp definied in
UrlSegmentOptions.ValidUrlCharacters
that does not allow for character 'ä' it will then use the charater map to see if the unallowed character should be replaced with something e.g. 'ä' => 'a' when the url segment is created
Thanks John for clarifing that.
Is there a similar character map for the segment parsing? Or any other way to replas characters before segment parsing?
There is no similar map used at routing. What you probably could do is hook up an event handler to
EPiServer.Web.Routing.IContentRouteEvents.RoutingContent
On the eventargs (of type RoutingEventArgs) you could access the path as args.RoutingSegmentContext.RemainingPath and update it (e.g. by replacing 'ä' => 'a')
This is the code for my sulotion based hon Johans sugestion. If anybody in the future should need it =)
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule),
typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class EventInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
var contentRouteEvents = ServiceLocator.Current.GetInstance<IContentRouteEvents>();
contentRouteEvents.RoutingContent += RoutingEvents_RoutingContent;
}
public void Uninitialize(InitializationEngine context)
{
}
private static void RoutingEvents_RoutingContent(object source, RoutingEventArgs e)
{
e.RoutingSegmentContext.RemainingPath = e.RoutingSegmentContext.RemainingPath.
Replace("ö", "o").
Replace("Ö", "o").
Replace("å", "a").
Replace("Å", "a").
Replace("ä", "a").
Replace("Ä", "a");
}
}
Hi,
According to https://world.episerver.com/documentation/developer-guides/CMS/routing/internationalized-resource-identifiers-iris/ (at the bottom of the page) CharacterMap in UrlSegmentOptions is a map for converting one char that is not suported in the url to another suported char.
"UrlSegmentOptions also exposes a CharacterMap property, where it is possible to define a mapping for unsupported characters, for example 'ö' => 'o'. "
But if I switch an "a" for an "ä" in a valid url I get a 404 resonse insted of the page for the valid url. Am I understanding the function of CharacterMap wrong?
I use CMS 10
Best regards
Jesper