Try our conversational search powered by Generative AI!

How does CharacterMap in UrlSegmentOptions work?



According to (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

Edited, Jun 09, 2017 11:11
Jun 09, 2017 12:41

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


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
Jun 12, 2017 9:59

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?

Jun 12, 2017 11:16

There is no similar map used at routing. What you probably could do is hook up an event handler to 


On the eventargs (of type RoutingEventArgs) you could access the path as args.RoutingSegmentContext.RemainingPath and update it (e.g. by replacing 'ä' => 'a')

Jun 12, 2017 11:56

Thanks again Johan!

I will look in to that possible solution.

Jun 12, 2017 12:21

This is the code for my sulotion based hon Johans sugestion. If anybody in the future should need it =)

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");

Jun 12, 2017 13:58
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.