Class UrlResolver
Class that routes an url to the corresponding IContent instance or vice versa.
Inheritance
Inherited Members
Namespace: EPiServer.Web.Routing
Assembly: EPiServer.dll
Version: 7.19.2Syntax
public class UrlResolverConstructors
UrlResolver()
Initializes a new instance of the UrlResolver class.
Declaration
public UrlResolver()UrlResolver(RouteCollection, IContentLoader, LanguageSelectorFactory, SiteDefinitionRepository, TemplateResolver, IPermanentLinkMapper)
Initializes a new instance of the UrlResolver class.
Declaration
public UrlResolver(RouteCollection routes, IContentLoader contentLoader, LanguageSelectorFactory languageSelectorFactory, SiteDefinitionRepository siteDefinitionRepository, TemplateResolver templateResolver, IPermanentLinkMapper permanentLinkMapper)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Web.Routing.RouteCollection | routes | The routes. | 
| IContentLoader | contentLoader | The content loader. | 
| LanguageSelectorFactory | languageSelectorFactory | The language selector factory. | 
| SiteDefinitionRepository | siteDefinitionRepository | The site definition repository. | 
| TemplateResolver | templateResolver | The template resolver. | 
| IPermanentLinkMapper | permanentLinkMapper | The permanent link mapper. | 
Properties
Current
Gets the current instance from the ServiceLocator.
Declaration
public static UrlResolver Current { get; }Property Value
| Type | Description | 
|---|---|
| UrlResolver | The current instance. | 
PreferredLanguageAccessor
Exposes the accessor used to get PreferredLanguage.
Declaration
public Func<string> PreferredLanguageAccessor { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Func<System.String> | The preferred language accessor. | 
Remarks
This is primarly exposed to make it possible to change in unit tests. By default the value is set PreferredCulture.
RoutedQueryParameters
Contains a list of query paramters that are passed on to routing.
Declaration
public static IEnumerable<string> RoutedQueryParameters { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.String> | 
Methods
ConvertPermanentToClassic(UrlBuilder)
Converts the permanent to classic.
Declaration
protected virtual string ConvertPermanentToClassic(UrlBuilder urlBuilder)Parameters
| Type | Name | Description | 
|---|---|---|
| UrlBuilder | urlBuilder | The URL builder. | 
Returns
| Type | Description | 
|---|---|
| System.String | 
Remarks
For internal use only
ConvertToPermanent(UrlBuilder, IContent)
Declaration
protected virtual bool ConvertToPermanent(UrlBuilder url, IContent content)Parameters
| Type | Name | Description | 
|---|---|---|
| UrlBuilder | url | |
| IContent | content | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
GetPermanent(String, Boolean)
Tries to resolve the URL to a permanent URL. If this does not possible it returns the original URL.
Declaration
public virtual string GetPermanent(string url, bool enableFallback)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | url | The URL. | 
| System.Boolean | enableFallback | If set to  | 
Returns
| Type | Description | 
|---|---|
| System.String | Either a permanent URL or the given URL/String.Empty depending on if fallback is enabled. | 
GetUrl(ContentReference)
Gets the URL for a IContent instance that is given by reference contentLink.
Declaration
public virtual string GetUrl(ContentReference contentLink)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content link. | 
Returns
| Type | Description | 
|---|---|
| System.String | A string representing the URL or  | 
Remarks
This method will get the URL for the language given by PreferredCulture.
GetUrl(ContentReference, String)
Gets the URL for a IContent instance that is given by reference contentLink
Declaration
public virtual string GetUrl(ContentReference contentLink, string language)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content. | 
| System.String | language | The language. | 
Returns
| Type | Description | 
|---|---|
| System.String | A string representing the URL or  | 
GetUrl(ContentReference, String, VirtualPathArguments)
Gets the URL for a IContent instance that is given by argument virtualPathArguments.
Declaration
public virtual string GetUrl(ContentReference contentLink, string language, VirtualPathArguments virtualPathArguments)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content link. | 
| System.String | language | The language. | 
| VirtualPathArguments | virtualPathArguments | The virtual path arguments. | 
Returns
| Type | Description | 
|---|---|
| System.String | A string representing the URL or  | 
GetUrl(UrlBuilder, ContextMode)
Resolves the URL for an item from an URL with internal format.
Declaration
public virtual string GetUrl(UrlBuilder urlBuilderWithInternalUrl, ContextMode mode)Parameters
| Type | Name | Description | 
|---|---|---|
| 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. | 
GetUrl(UrlBuilder, VirtualPathArguments)
Resolves the URL for an item from an URL with internal format.
Declaration
public virtual 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. | 
GetUrl(Guid)
Resolves the URL for an item from a guid format.
Declaration
protected virtual string GetUrl(Guid contentGuid)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Guid | contentGuid | The content guid. | 
Returns
| Type | Description | 
|---|---|
| System.String | A URL in string representation. | 
Remarks
This member supports the EPiServer infrastructure and is not intended to be used directly from your code.
GetUrl(String)
Resolves the URL for an item from an URL with internal format.
Declaration
public virtual string GetUrl(string internalUrl)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | internalUrl | The URL with a internal format. | 
Returns
| Type | Description | 
|---|---|
| System.String | A URL in string representation. | 
GetVirtualPath(ContentReference)
Declaration
[Obsolete("Use GetUrl instead.", false)]
public virtual string GetVirtualPath(ContentReference contentLink)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content. | 
Returns
| Type | Description | 
|---|---|
| System.String | 
Remarks
This method will get the url for the language given by PreferredCulture.
GetVirtualPath(ContentReference, String)
Gets the url for a IContent instance that is given by reference contentLink
Declaration
[Obsolete("Use GetUrl instead.", false)]
public virtual string GetVirtualPath(ContentReference contentLink, string language)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content. | 
| System.String | language | The language. | 
Returns
| Type | Description | 
|---|---|
| System.String | 
GetVirtualPath(ContentReference, String, VirtualPathArguments)
Gets the url for a IContent instance that is given by reference virtualPathArguments
Declaration
public virtual VirtualPathData GetVirtualPath(ContentReference contentLink, string language, VirtualPathArguments virtualPathArguments)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content link. | 
| System.String | language | The language. | 
| VirtualPathArguments | virtualPathArguments | The virtual path arguments. | 
Returns
| Type | Description | 
|---|---|
| System.Web.Routing.VirtualPathData | A virtual path or  | 
GetVirtualPath(ContentReference, String, RouteValueDictionary, RequestContext)
Gets the url for a IContent instance that is given by reference contentLink
Declaration
public virtual VirtualPathData GetVirtualPath(ContentReference contentLink, string language, RouteValueDictionary routeValues, RequestContext requestContext)Parameters
| Type | Name | Description | 
|---|---|---|
| ContentReference | contentLink | The content. | 
| System.String | language | The language. | 
| System.Web.Routing.RouteValueDictionary | routeValues | The route values. | 
| System.Web.Routing.RequestContext | requestContext | The request context. | 
Returns
| Type | Description | 
|---|---|
| System.Web.Routing.VirtualPathData | A virtual path or  | 
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 virtual 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 | 
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.
GetVirtualPathForPartialRouted(Object, String)
Declaration
[Obsolete("Use GetVirtualPathForNonContent")]
public virtual VirtualPathData GetVirtualPathForPartialRouted(object partialRoutedObject, string language)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | partialRoutedObject | |
| System.String | language | 
Returns
| Type | Description | 
|---|---|
| System.Web.Routing.VirtualPathData | 
Route(UrlBuilder)
Routes the URL to the corresponding IContent instance.
Declaration
public virtual IContent Route(UrlBuilder urlBuilder)Parameters
| Type | Name | Description | 
|---|---|---|
| UrlBuilder | urlBuilder | The URL builder. | 
Returns
| Type | Description | 
|---|---|
| IContent | 
Route(UrlBuilder, ContextMode)
Routes the URL to the corresponding IContent instance.
Declaration
public virtual IContent Route(UrlBuilder urlBuilder, ContextMode contextMode)Parameters
| Type | Name | Description | 
|---|---|---|
| UrlBuilder | urlBuilder | The URL builder. | 
| ContextMode | contextMode | The ContextMode | 
Returns
| Type | Description | 
|---|---|
| IContent | 
TryToPermanent(String, out String)
Tries to convert a URL with either a public, preview or permanent format to a permanent URL.
Declaration
public virtual 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. | 
