Loading...

Last updated: Dec 18 2017

Area: Episerver CMS Applies to versions: 11.3 and higher
Other versions:

Internationalized Resource Identifiers (IRIs)

This topic describes how international characters are handled for URLs in Episerver.

How it works

When creating URL segments (typically from content name) or simple address, by default, Episerver only allows characters according to RFC 1738, which basically allows ALPHA / DIGIT / '-'/ '_'/ '~' / '.'/ '$'/. 

You can define a custom character set to be used. To do this, update the UrlSegmentOptions configuration in the IOC container. When a character set is defined that allows characters outside RFC 1738, the setting UrlSegementOptions.SupportIriCharacters should be set to true so that URLs gets properly encoded. Below is an example of a character set that allows unicode characters in the letter category.

using EPiServer.ServiceLocation;
using EPiServer.Framework.Initialization;
using EPiServer.Framework;
using EPiServer.Web;

namespace EPiServerSite
{
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class IRIConfigurationModule : IConfigurableModule
    {
        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Services.Configure<UrlSegmentOptions>(o =>
            {
                o.SupportIriCharacters = true,
                o.ValidCharacters = @"\p{L}0-9\-_~\.\$"
            });
        }

        public void Initialize(InitializationEngine context) { }
        public void Uninitialize(InitializationEngine context) { }
    }
}

UrlSegmentOptions also exposes a CharacterMap property, where it is possible to define a mapping for unsupported characters, for example 'ö' => 'o'. 

Internationalized Domain Names (IDN)

As explained in IDN and IRI, internationalized domain names are registered in punycode format (a way of representing Unicode characters using only ASCII characters). 

Internationalized domain names should be registered in their punycode format in the CMS admin view under Manage Websites.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/