Try our conversational search powered by Generative AI!

Class UrlResolverExtensions

Extends IUrlResolver with convenient methods

Inheritance
System.Object
UrlResolverExtensions
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.Web.Routing
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
public static class UrlResolverExtensions

Methods

GetPermanent(IUrlResolver, String, Boolean)

Tries to resolve the URL to a permanent URL. If this does not possible it returns the original URL.

Declaration
public static string GetPermanent(this IUrlResolver urlResolver, string url, bool enableFallback)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

System.String url

The URL.

System.Boolean enableFallback

If set to true returns the given URL if the conversion fails.

Returns
Type Description
System.String

Either a permanent URL or the given URL/String.Empty depending on if fallback is enabled.

GetUrl(IUrlResolver, ContentReference)

Gets the URL for a IContent instance that is given by reference contentLink.

Declaration
public static string GetUrl(this IUrlResolver urlResolver, ContentReference contentLink)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

ContentReference contentLink

The content link.

Returns
Type Description
System.String

A string representing the URL or null if it was not possible to create a route to the content

Remarks

The returned url can be relative or absolute (including host) depending on if the contentLink is on current site and current request matches host that matches content and language.

GetUrl(IUrlResolver, ContentReference, String)

Gets the URL for a IContent instance that is given by reference contentLink

Declaration
public static string GetUrl(this IUrlResolver urlResolver, ContentReference contentLink, string language)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

ContentReference contentLink

The content.

System.String language

The language.

Returns
Type Description
System.String

A string representing the URL or null if it was not possible to create a route to the content

Remarks

The returned url can be relative or absolute (including host) depending on if the contentLink is on current site and current request matches host that matches content and language.

GetUrl(IUrlResolver, IContent)

Gets the URL for the content instance.

Declaration
public static string GetUrl(this IUrlResolver urlResolver, IContent content)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

IContent content

The content instance.

Returns
Type Description
System.String

A string representing the URL or null if it was not possible to create a route to the content

Remarks

The returned url can be relative or absolute (including host) depending on if the content is on current site and current request matches host that matches content and language.

GetUrl(IUrlResolver, UrlBuilder, ContextMode)

Resolves the URL for an item from an URL with internal format.

Declaration
public static string GetUrl(this IUrlResolver urlResolver, UrlBuilder urlBuilderWithInternalUrl, ContextMode mode)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

UrlBuilder urlBuilderWithInternalUrl

The URL with a internal format.

ContextMode mode

The ContextMode that determines the format of the link.

Returns
Type Description
System.String

A URL in string representation.

Remarks

The returned url can be relative or absolute (including host) depending on if the urlBuilderWithInternalUrl is on current site and current request matches host that matches content and language.

GetUrl(IUrlResolver, String)

Resolves the URL for an item from an URL with internal format.

Declaration
public static string GetUrl(this IUrlResolver urlResolver, string internalUrl)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

System.String internalUrl

The URL with a internal format.

Returns
Type Description
System.String

A URL in string representation.

Remarks

The returned url can be relative or absolute (including host) depending on if the internalUrl is on current site and current request matches host that matches content and language.

Route(IUrlResolver, UrlBuilder)

Routes the URL to the corresponding IContent instance.

Declaration
public static IContent Route(this IUrlResolver urlResolver, UrlBuilder urlBuilder)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

UrlBuilder urlBuilder

The URL builder.

Returns
Type Description
IContent