SaaS CMS has officially launched! Learn more now.

Class SiteMappingConfiguration

Handles mapping from host names on incoming requests to the correct site id.

Inheritance
System.Object
SiteMappingConfiguration
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Framework.Initialization
Assembly: EPiServer.Framework.dll
Version: 8.11.0
Syntax
[Obsolete("Use EPiServer.Web.SiteDefinitionRepository and SiteDefinition in EPiServer.dll to work with sites")]
public class SiteMappingConfiguration : IInitializableModule

Constructors

SiteMappingConfiguration()

Declaration
public SiteMappingConfiguration()

Fields

WildcardHostName

The host name that is used for the fallback SiteId

Declaration
public const string WildcardHostName = "*"
Field Value
Type Description
System.String

WildcardSiteId

The SiteId reported in case of missing config

Declaration
public const string WildcardSiteId = "*"
Field Value
Type Description
System.String

Properties

CurrentHostNameResolver

Gets or sets the resolver used to resolve the current executing hostname

Declaration
public static Func<string> CurrentHostNameResolver { get; set; }
Property Value
Type Description
System.Func<System.String>

The current host name resolver.

Instance

Gets or sets the singleton instance of the ISiteMapping implementation.

Declaration
public static SiteMappingConfiguration Instance { get; set; }
Property Value
Type Description
SiteMappingConfiguration

The instance.

SiteId

Gets or sets the site id.

Declaration
public string SiteId { get; set; }
Property Value
Type Description
System.String

The site id.

Methods

AddSiteHostMapping(String, String, String)

Adds a new host name to site id mapping in the in-memory lookup

Declaration
[Obsolete("Use EPiServer.Web.SiteDefinitionRepository and SiteDefinition in EPiServer.dll to work with sites. EPiServer.Globalization.HostLanguageResolver can be used to get language mappings for hosts")]
public void AddSiteHostMapping(string hostName, string siteId, string language)
Parameters
Type Name Description
System.String hostName

Name of the host.

System.String siteId

The site id.

System.String language

The language. Can be null if no language defined.

HostToLanguageMapForSite(String)

Gets a dictionary with mappings from host name to language that are valid for the given site.

Declaration
[Obsolete("Use EPiServer.Web.SiteDefinitionRepository and SiteDefinition in EPiServer.dll to work with sites. EPiServer.Globalization.HostLanguageResolver can be used to get language mappings for hosts")]
public IDictionary<string, string> HostToLanguageMapForSite(string siteId)
Parameters
Type Name Description
System.String siteId

The site id.

Returns
Type Description
System.Collections.Generic.IDictionary<System.String, System.String>

A dictionary with the host name as the key and the language as the value. If language is not defined, then value is null.

Initialize(InitializationEngine)

Declaration
public void Initialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

InitializeFromConfig(SiteHostsCollection)

Initializes the instance from config data

Declaration
public void InitializeFromConfig(SiteHostsCollection siteHosts)
Parameters
Type Name Description
SiteHostsCollection siteHosts

The site hosts.

LanguageForHost(String)

Gets the language to use for host.

Declaration
[Obsolete("Use EPiServer.Web.SiteDefinitionRepository and SiteDefinition in EPiServer.dll to work with sites. EPiServer.Globalization.HostLanguageResolver can be used to get language mappings for hosts")]
public string LanguageForHost(string hostName)
Parameters
Type Name Description
System.String hostName

Name of the host.

Returns
Type Description
System.String

The language name.

SiteIdForDefinedHost(String)

Gets the SiteId that corresponds to host.

Declaration
[Obsolete("Use EPiServer.Web.SiteDefinitionRepository and SiteDefinition in EPiServer.dll to work with sites. EPiServer.Globalization.HostLanguageResolver can be used to get language mappings for hosts")]
public string SiteIdForDefinedHost(string hostName)
Parameters
Type Name Description
System.String hostName

Name of the host.

Returns
Type Description
System.String

The site id or null if the host name does not exist.

SiteIdForHost(String)

Gets the SiteId that corresponds to host.

Declaration
[Obsolete("Use EPiServer.Web.SiteDefinitionRepository and SiteDefinition in EPiServer.dll to work with sites. EPiServer.Globalization.HostLanguageResolver can be used to get language mappings for hosts")]
public string SiteIdForHost(string hostName)
Parameters
Type Name Description
System.String hostName

Name of the host.

Returns
Type Description
System.String

The site id.

SiteIdFromRequest()

Gets the Site ID for the site that should service the current HTTP request.

Declaration
public string SiteIdFromRequest()
Returns
Type Description
System.String

The Site ID if we have a valid HttpContex; otherwise null.

Uninitialize(InitializationEngine)

Declaration
public void Uninitialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

VerifySiteId()

Verifies that the current Site ID matches the host name as present in the current request.

Declaration
public void VerifySiteId()
Exceptions
Type Condition
ConfigurationErrorsException

Thrown if there is a mismatch between expected and actual site mapping

Implements