SaaS CMS has officially launched! Learn more now.

Class DefaultUrlResolver

The default implementation of UrlResolver

Inheritance
System.Object
DefaultUrlResolver
Namespace: EPiServer.Web.Routing
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
[ServiceConfiguration(typeof(UrlResolver))]
public class DefaultUrlResolver : UrlResolver

Constructors

DefaultUrlResolver(RouteCollection, IContentLoader, SiteDefinitionRepository, TemplateResolver, IPermanentLinkMapper)

Creates a new instace of DefaultUrlResolver

Declaration
public DefaultUrlResolver(RouteCollection routes, IContentLoader contentLoader, SiteDefinitionRepository siteDefinitionRepository, TemplateResolver templateResolver, IPermanentLinkMapper permanentLinkMapper)
Parameters
Type Name Description
System.Web.Routing.RouteCollection routes

The registered routes to use.

IContentLoader contentLoader

The content loader to use

SiteDefinitionRepository siteDefinitionRepository

The site definition repository to use

TemplateResolver templateResolver

The template resolver to use

IPermanentLinkMapper permanentLinkMapper

The permanent link mapper to use

Methods

ConvertToPermanent(UrlBuilder, IContent)

Converts an url for content to permanent format.

Declaration
protected override bool ConvertToPermanent(UrlBuilder url, IContent content)
Parameters
Type Name Description
UrlBuilder url

The url to convert

IContent content

The content to create permanent format for.

Returns
Type Description
System.Boolean

true if the url was converted else false.

Overrides

GetUrl(UrlBuilder, VirtualPathArguments)

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

Declaration
public override string GetUrl(UrlBuilder urlBuilderWithInternalUrl, VirtualPathArguments arguments)
Parameters
Type Name Description
UrlBuilder urlBuilderWithInternalUrl

The URL with a internal format.

VirtualPathArguments arguments

The VirtualPathArguments that determines the format of the link.

Returns
Type Description
System.String

A URL in string representation.

Overrides
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. Overload GetVirtualPath can be used to always get relative virtual path.

GetVirtualPathForNonContent(Object, String, VirtualPathArguments)

Gets the virtual path for an object that is not an IContent object but has been routed by a partial router.

Declaration
public override VirtualPathData GetVirtualPathForNonContent(object partialRoutedObject, string language, VirtualPathArguments virtualPathArguments)
Parameters
Type Name Description
System.Object partialRoutedObject

The partial routed object.

System.String language

The language.

VirtualPathArguments virtualPathArguments

The virtual path arguments.

Returns
Type Description
System.Web.Routing.VirtualPathData
Overrides
Remarks

For virtual path to IContent, use the GetVirtualPath method with the content's ContentReference, which also handles cases where the content is partial routed.

The returned value System.Web.Routing.VirtualPathData.VirtualPath is always a relative path (host and application is not included), call extension method GetUrl on VirtualPathData to get an absolute path (there is an overload that can be used if authority part should not be included).

GetVirtualPathInternal(ContentReference, String, VirtualPathArguments)

Tries to get the URL for a content and mode and returns a System.Web.Routing.VirtualPathData that contains the routing information.

Declaration
protected override VirtualPathData GetVirtualPathInternal(ContentReference contentLink, string language, VirtualPathArguments arguments)
Parameters
Type Name Description
ContentReference contentLink
System.String language
VirtualPathArguments arguments
Returns
Type Description
System.Web.Routing.VirtualPathData

A virtual path or null if it was not possible to create a route to the content (for example the content does not exist or has no template)

Overrides

Route(UrlBuilder, ContextMode)

Routes the URL to the corresponding IContent instance.

Declaration
public override IContent Route(UrlBuilder urlBuilder, ContextMode contextMode)
Parameters
Type Name Description
UrlBuilder urlBuilder

The URL builder.

ContextMode contextMode

The ContextMode

Returns
Type Description
IContent
Overrides

TryToPermanent(String, out String)

Tries to convert a URL with either a public, preview or permanent format to a permanent URL.

Declaration
public override bool TryToPermanent(string url, out string permanentUrl)
Parameters
Type Name Description
System.String url

The URL.

System.String permanentUrl

The permanent URL.

Returns
Type Description
System.Boolean

True if the conversion succeded, otherwise; false.

Overrides

Extension Methods