November Happy Hour will be moved to Thursday December 5th.

Class UrlResolverExtensions

Extends IUrlResolver with convenient methods

Inheritance
System.Object
UrlResolverExtensions
Namespace: EPiServer.Web.Routing
Assembly: EPiServer.dll
Version: 12.0.3
Syntax
public static class UrlResolverExtensions : Object

Methods

GetPartialRoutedUrl(IUrlResolver, Object)

Generates an url for an object that is handled by a IPartialRouter<TContent, TRoutedData> implementation.

Declaration
public static string GetPartialRoutedUrl(this IUrlResolver urlResolver, object partialRoutedObject)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

System.Object partialRoutedObject

The partial routed object

Returns
Type Description
System.String

A URL in string representation.

GetPartialRoutedUrl(IUrlResolver, Object, UrlResolverArguments)

Generates an url for an object that is handled by a IPartialRouter<TContent, TRoutedData> implementation.

Declaration
public static string GetPartialRoutedUrl(this IUrlResolver urlResolver, object partialRoutedObject, UrlResolverArguments urlResolverArguments)
Parameters
Type Name Description
IUrlResolver urlResolver

The url resolver that is extended

System.Object partialRoutedObject

The partial routed object

UrlResolverArguments urlResolverArguments

url resolver arguments

Returns
Type Description
System.String

A URL in string representation.

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

Route(IUrlResolver, UrlBuilder, ContextMode)

Routes the URL to the corresponding IContent instance.

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

The url resolver that is extended

UrlBuilder urlBuilder

The URL builder.

ContextMode contextMode

The context mode to resolve the url in

Returns
Type Description
IContent